
obj/user/primespipe:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 93 02 00 00       	call   8002c4 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <primeproc>:

#include <inc/lib.h>

unsigned
primeproc(int fd)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	57                   	push   %edi
  800038:	56                   	push   %esi
  800039:	53                   	push   %ebx
  80003a:	83 ec 3c             	sub    $0x3c,%esp
  80003d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int i, id, p, pfd[2], wfd, r;

	// fetch a prime from our left neighbor
top:
	if ((r = readn(fd, &p, 4)) != 4)
  800040:	8d 75 e0             	lea    -0x20(%ebp),%esi
		panic("primeproc could not read initial prime: %d, %e", r, r >= 0 ? 0 : r);

	cprintf("%d\n", p);

	// fork a right neighbor to continue the chain
	if ((i=pipe(pfd)) < 0)
  800043:	8d 7d d8             	lea    -0x28(%ebp),%edi
{
	int i, id, p, pfd[2], wfd, r;

	// fetch a prime from our left neighbor
top:
	if ((r = readn(fd, &p, 4)) != 4)
  800046:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  80004d:	00 
  80004e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800052:	89 1c 24             	mov    %ebx,(%esp)
  800055:	e8 d7 1a 00 00       	call   801b31 <readn>
  80005a:	83 f8 04             	cmp    $0x4,%eax
  80005d:	74 2e                	je     80008d <primeproc+0x59>
		panic("primeproc could not read initial prime: %d, %e", r, r >= 0 ? 0 : r);
  80005f:	85 c0                	test   %eax,%eax
  800061:	ba 00 00 00 00       	mov    $0x0,%edx
  800066:	0f 4e d0             	cmovle %eax,%edx
  800069:	89 54 24 10          	mov    %edx,0x10(%esp)
  80006d:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800071:	c7 44 24 08 00 2f 80 	movl   $0x802f00,0x8(%esp)
  800078:	00 
  800079:	c7 44 24 04 15 00 00 	movl   $0x15,0x4(%esp)
  800080:	00 
  800081:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  800088:	e8 a3 02 00 00       	call   800330 <_panic>

	cprintf("%d\n", p);
  80008d:	8b 45 e0             	mov    -0x20(%ebp),%eax
  800090:	89 44 24 04          	mov    %eax,0x4(%esp)
  800094:	c7 04 24 98 33 80 00 	movl   $0x803398,(%esp)
  80009b:	e8 55 03 00 00       	call   8003f5 <cprintf>

	// fork a right neighbor to continue the chain
	if ((i=pipe(pfd)) < 0)
  8000a0:	89 3c 24             	mov    %edi,(%esp)
  8000a3:	e8 01 27 00 00       	call   8027a9 <pipe>
  8000a8:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8000ab:	85 c0                	test   %eax,%eax
  8000ad:	79 20                	jns    8000cf <primeproc+0x9b>
		panic("pipe: %e", i);
  8000af:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000b3:	c7 44 24 08 41 2f 80 	movl   $0x802f41,0x8(%esp)
  8000ba:	00 
  8000bb:	c7 44 24 04 1b 00 00 	movl   $0x1b,0x4(%esp)
  8000c2:	00 
  8000c3:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  8000ca:	e8 61 02 00 00       	call   800330 <_panic>
	if ((id = fork()) < 0)
  8000cf:	e8 9e 12 00 00       	call   801372 <fork>
  8000d4:	85 c0                	test   %eax,%eax
  8000d6:	79 20                	jns    8000f8 <primeproc+0xc4>
		panic("fork: %e", id);
  8000d8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8000dc:	c7 44 24 08 4a 2f 80 	movl   $0x802f4a,0x8(%esp)
  8000e3:	00 
  8000e4:	c7 44 24 04 1d 00 00 	movl   $0x1d,0x4(%esp)
  8000eb:	00 
  8000ec:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  8000f3:	e8 38 02 00 00       	call   800330 <_panic>
	if (id == 0) {
  8000f8:	85 c0                	test   %eax,%eax
  8000fa:	75 1b                	jne    800117 <primeproc+0xe3>
		close(fd);
  8000fc:	89 1c 24             	mov    %ebx,(%esp)
  8000ff:	e8 08 1b 00 00       	call   801c0c <close>
		close(pfd[1]);
  800104:	8b 45 dc             	mov    -0x24(%ebp),%eax
  800107:	89 04 24             	mov    %eax,(%esp)
  80010a:	e8 fd 1a 00 00       	call   801c0c <close>
		fd = pfd[0];
  80010f:	8b 5d d8             	mov    -0x28(%ebp),%ebx
		goto top;
  800112:	e9 2f ff ff ff       	jmp    800046 <primeproc+0x12>
	}

	close(pfd[0]);
  800117:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80011a:	89 04 24             	mov    %eax,(%esp)
  80011d:	e8 ea 1a 00 00       	call   801c0c <close>
	wfd = pfd[1];
  800122:	8b 7d dc             	mov    -0x24(%ebp),%edi

	// filter out multiples of our prime
	for (;;) {
		if ((r=readn(fd, &i, 4)) != 4)
  800125:	8d 75 e4             	lea    -0x1c(%ebp),%esi
  800128:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  80012f:	00 
  800130:	89 74 24 04          	mov    %esi,0x4(%esp)
  800134:	89 1c 24             	mov    %ebx,(%esp)
  800137:	e8 f5 19 00 00       	call   801b31 <readn>
  80013c:	83 f8 04             	cmp    $0x4,%eax
  80013f:	74 39                	je     80017a <primeproc+0x146>
			panic("primeproc %d readn %d %d %e", p, fd, r, r >= 0 ? 0 : r);
  800141:	85 c0                	test   %eax,%eax
  800143:	ba 00 00 00 00       	mov    $0x0,%edx
  800148:	0f 4e d0             	cmovle %eax,%edx
  80014b:	89 54 24 18          	mov    %edx,0x18(%esp)
  80014f:	89 44 24 14          	mov    %eax,0x14(%esp)
  800153:	89 5c 24 10          	mov    %ebx,0x10(%esp)
  800157:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80015a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80015e:	c7 44 24 08 53 2f 80 	movl   $0x802f53,0x8(%esp)
  800165:	00 
  800166:	c7 44 24 04 2b 00 00 	movl   $0x2b,0x4(%esp)
  80016d:	00 
  80016e:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  800175:	e8 b6 01 00 00       	call   800330 <_panic>
		if (i%p)
  80017a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80017d:	89 d0                	mov    %edx,%eax
  80017f:	c1 fa 1f             	sar    $0x1f,%edx
  800182:	f7 7d e0             	idivl  -0x20(%ebp)
  800185:	85 d2                	test   %edx,%edx
  800187:	74 9f                	je     800128 <primeproc+0xf4>
			if ((r=write(wfd, &i, 4)) != 4)
  800189:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  800190:	00 
  800191:	89 74 24 04          	mov    %esi,0x4(%esp)
  800195:	89 3c 24             	mov    %edi,(%esp)
  800198:	e8 2d 18 00 00       	call   8019ca <write>
  80019d:	83 f8 04             	cmp    $0x4,%eax
  8001a0:	74 86                	je     800128 <primeproc+0xf4>
				panic("primeproc %d write: %d %e", p, r, r >= 0 ? 0 : r);
  8001a2:	85 c0                	test   %eax,%eax
  8001a4:	ba 00 00 00 00       	mov    $0x0,%edx
  8001a9:	0f 4e d0             	cmovle %eax,%edx
  8001ac:	89 54 24 14          	mov    %edx,0x14(%esp)
  8001b0:	89 44 24 10          	mov    %eax,0x10(%esp)
  8001b4:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8001b7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001bb:	c7 44 24 08 6f 2f 80 	movl   $0x802f6f,0x8(%esp)
  8001c2:	00 
  8001c3:	c7 44 24 04 2e 00 00 	movl   $0x2e,0x4(%esp)
  8001ca:	00 
  8001cb:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  8001d2:	e8 59 01 00 00       	call   800330 <_panic>

008001d7 <umain>:
	}
}

void
umain(void)
{
  8001d7:	55                   	push   %ebp
  8001d8:	89 e5                	mov    %esp,%ebp
  8001da:	53                   	push   %ebx
  8001db:	83 ec 34             	sub    $0x34,%esp
	int i, id, p[2], r;

	argv0 = "primespipe";
  8001de:	c7 05 78 70 80 00 89 	movl   $0x802f89,0x807078
  8001e5:	2f 80 00 

	if ((i=pipe(p)) < 0)
  8001e8:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8001eb:	89 04 24             	mov    %eax,(%esp)
  8001ee:	e8 b6 25 00 00       	call   8027a9 <pipe>
  8001f3:	89 45 f4             	mov    %eax,-0xc(%ebp)
  8001f6:	85 c0                	test   %eax,%eax
  8001f8:	79 20                	jns    80021a <umain+0x43>
		panic("pipe: %e", i);
  8001fa:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001fe:	c7 44 24 08 41 2f 80 	movl   $0x802f41,0x8(%esp)
  800205:	00 
  800206:	c7 44 24 04 3a 00 00 	movl   $0x3a,0x4(%esp)
  80020d:	00 
  80020e:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  800215:	e8 16 01 00 00       	call   800330 <_panic>

	// fork the first prime process in the chain
	if ((id=fork()) < 0)
  80021a:	e8 53 11 00 00       	call   801372 <fork>
  80021f:	85 c0                	test   %eax,%eax
  800221:	79 20                	jns    800243 <umain+0x6c>
		panic("fork: %e", id);
  800223:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800227:	c7 44 24 08 4a 2f 80 	movl   $0x802f4a,0x8(%esp)
  80022e:	00 
  80022f:	c7 44 24 04 3e 00 00 	movl   $0x3e,0x4(%esp)
  800236:	00 
  800237:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  80023e:	e8 ed 00 00 00       	call   800330 <_panic>

	if (id == 0) {
  800243:	85 c0                	test   %eax,%eax
  800245:	75 16                	jne    80025d <umain+0x86>
		close(p[1]);
  800247:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80024a:	89 04 24             	mov    %eax,(%esp)
  80024d:	e8 ba 19 00 00       	call   801c0c <close>
		primeproc(p[0]);
  800252:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800255:	89 04 24             	mov    %eax,(%esp)
  800258:	e8 d7 fd ff ff       	call   800034 <primeproc>
	}

	close(p[0]);
  80025d:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800260:	89 04 24             	mov    %eax,(%esp)
  800263:	e8 a4 19 00 00       	call   801c0c <close>

	// feed all the integers through
	for (i=2;; i++)
  800268:	c7 45 f4 02 00 00 00 	movl   $0x2,-0xc(%ebp)
		if ((r=write(p[1], &i, 4)) != 4)
  80026f:	8d 5d f4             	lea    -0xc(%ebp),%ebx
  800272:	c7 44 24 08 04 00 00 	movl   $0x4,0x8(%esp)
  800279:	00 
  80027a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80027e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800281:	89 04 24             	mov    %eax,(%esp)
  800284:	e8 41 17 00 00       	call   8019ca <write>
  800289:	83 f8 04             	cmp    $0x4,%eax
  80028c:	74 2e                	je     8002bc <umain+0xe5>
			panic("generator write: %d, %e", r, r >= 0 ? 0 : r);
  80028e:	85 c0                	test   %eax,%eax
  800290:	ba 00 00 00 00       	mov    $0x0,%edx
  800295:	0f 4e d0             	cmovle %eax,%edx
  800298:	89 54 24 10          	mov    %edx,0x10(%esp)
  80029c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8002a0:	c7 44 24 08 94 2f 80 	movl   $0x802f94,0x8(%esp)
  8002a7:	00 
  8002a8:	c7 44 24 04 4a 00 00 	movl   $0x4a,0x4(%esp)
  8002af:	00 
  8002b0:	c7 04 24 2f 2f 80 00 	movl   $0x802f2f,(%esp)
  8002b7:	e8 74 00 00 00       	call   800330 <_panic>
	}

	close(p[0]);

	// feed all the integers through
	for (i=2;; i++)
  8002bc:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)
		if ((r=write(p[1], &i, 4)) != 4)
			panic("generator write: %d, %e", r, r >= 0 ? 0 : r);
}
  8002c0:	eb b0                	jmp    800272 <umain+0x9b>
	...

008002c4 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8002c4:	55                   	push   %ebp
  8002c5:	89 e5                	mov    %esp,%ebp
  8002c7:	83 ec 18             	sub    $0x18,%esp
  8002ca:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8002cd:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8002d0:	8b 75 08             	mov    0x8(%ebp),%esi
  8002d3:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8002d6:	e8 de 0f 00 00       	call   8012b9 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8002db:	25 ff 03 00 00       	and    $0x3ff,%eax
  8002e0:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8002e3:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8002e8:	a3 74 70 80 00       	mov    %eax,0x807074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8002ed:	85 f6                	test   %esi,%esi
  8002ef:	7e 07                	jle    8002f8 <libmain+0x34>
		binaryname = argv[0];
  8002f1:	8b 03                	mov    (%ebx),%eax
  8002f3:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  8002f8:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8002fc:	89 34 24             	mov    %esi,(%esp)
  8002ff:	e8 d3 fe ff ff       	call   8001d7 <umain>

	// exit gracefully
	exit();
  800304:	e8 0b 00 00 00       	call   800314 <exit>
}
  800309:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80030c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80030f:	89 ec                	mov    %ebp,%esp
  800311:	5d                   	pop    %ebp
  800312:	c3                   	ret    
	...

00800314 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  800314:	55                   	push   %ebp
  800315:	89 e5                	mov    %esp,%ebp
  800317:	83 ec 18             	sub    $0x18,%esp
	close_all();
  80031a:	e8 6a 19 00 00       	call   801c89 <close_all>
	sys_env_destroy(0);
  80031f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800326:	e8 c2 0f 00 00       	call   8012ed <sys_env_destroy>
}
  80032b:	c9                   	leave  
  80032c:	c3                   	ret    
  80032d:	00 00                	add    %al,(%eax)
	...

00800330 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800330:	55                   	push   %ebp
  800331:	89 e5                	mov    %esp,%ebp
  800333:	53                   	push   %ebx
  800334:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800337:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80033a:	a1 78 70 80 00       	mov    0x807078,%eax
  80033f:	85 c0                	test   %eax,%eax
  800341:	74 10                	je     800353 <_panic+0x23>
		cprintf("%s: ", argv0);
  800343:	89 44 24 04          	mov    %eax,0x4(%esp)
  800347:	c7 04 24 c3 2f 80 00 	movl   $0x802fc3,(%esp)
  80034e:	e8 a2 00 00 00       	call   8003f5 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800353:	8b 45 0c             	mov    0xc(%ebp),%eax
  800356:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80035a:	8b 45 08             	mov    0x8(%ebp),%eax
  80035d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800361:	a1 00 70 80 00       	mov    0x807000,%eax
  800366:	89 44 24 04          	mov    %eax,0x4(%esp)
  80036a:	c7 04 24 c8 2f 80 00 	movl   $0x802fc8,(%esp)
  800371:	e8 7f 00 00 00       	call   8003f5 <cprintf>
	vcprintf(fmt, ap);
  800376:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80037a:	8b 45 10             	mov    0x10(%ebp),%eax
  80037d:	89 04 24             	mov    %eax,(%esp)
  800380:	e8 0f 00 00 00       	call   800394 <vcprintf>
	cprintf("\n");
  800385:	c7 04 24 47 33 80 00 	movl   $0x803347,(%esp)
  80038c:	e8 64 00 00 00       	call   8003f5 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800391:	cc                   	int3   
  800392:	eb fd                	jmp    800391 <_panic+0x61>

00800394 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800394:	55                   	push   %ebp
  800395:	89 e5                	mov    %esp,%ebp
  800397:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  80039d:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  8003a4:	00 00 00 
	b.cnt = 0;
  8003a7:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  8003ae:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  8003b1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8003b4:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8003b8:	8b 45 08             	mov    0x8(%ebp),%eax
  8003bb:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003bf:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  8003c5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003c9:	c7 04 24 0f 04 80 00 	movl   $0x80040f,(%esp)
  8003d0:	e8 d8 01 00 00       	call   8005ad <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8003d5:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8003db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8003df:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8003e5:	89 04 24             	mov    %eax,(%esp)
  8003e8:	e8 d3 0a 00 00       	call   800ec0 <sys_cputs>

	return b.cnt;
}
  8003ed:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8003f3:	c9                   	leave  
  8003f4:	c3                   	ret    

008003f5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8003f5:	55                   	push   %ebp
  8003f6:	89 e5                	mov    %esp,%ebp
  8003f8:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8003fb:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8003fe:	89 44 24 04          	mov    %eax,0x4(%esp)
  800402:	8b 45 08             	mov    0x8(%ebp),%eax
  800405:	89 04 24             	mov    %eax,(%esp)
  800408:	e8 87 ff ff ff       	call   800394 <vcprintf>
	va_end(ap);

	return cnt;
}
  80040d:	c9                   	leave  
  80040e:	c3                   	ret    

0080040f <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  80040f:	55                   	push   %ebp
  800410:	89 e5                	mov    %esp,%ebp
  800412:	53                   	push   %ebx
  800413:	83 ec 14             	sub    $0x14,%esp
  800416:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  800419:	8b 03                	mov    (%ebx),%eax
  80041b:	8b 55 08             	mov    0x8(%ebp),%edx
  80041e:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  800422:	83 c0 01             	add    $0x1,%eax
  800425:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  800427:	3d ff 00 00 00       	cmp    $0xff,%eax
  80042c:	75 19                	jne    800447 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  80042e:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800435:	00 
  800436:	8d 43 08             	lea    0x8(%ebx),%eax
  800439:	89 04 24             	mov    %eax,(%esp)
  80043c:	e8 7f 0a 00 00       	call   800ec0 <sys_cputs>
		b->idx = 0;
  800441:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800447:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80044b:	83 c4 14             	add    $0x14,%esp
  80044e:	5b                   	pop    %ebx
  80044f:	5d                   	pop    %ebp
  800450:	c3                   	ret    
	...

00800460 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800460:	55                   	push   %ebp
  800461:	89 e5                	mov    %esp,%ebp
  800463:	57                   	push   %edi
  800464:	56                   	push   %esi
  800465:	53                   	push   %ebx
  800466:	83 ec 4c             	sub    $0x4c,%esp
  800469:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80046c:	89 d6                	mov    %edx,%esi
  80046e:	8b 45 08             	mov    0x8(%ebp),%eax
  800471:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800474:	8b 55 0c             	mov    0xc(%ebp),%edx
  800477:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80047a:	8b 45 10             	mov    0x10(%ebp),%eax
  80047d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800480:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800483:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800486:	b9 00 00 00 00       	mov    $0x0,%ecx
  80048b:	39 d1                	cmp    %edx,%ecx
  80048d:	72 15                	jb     8004a4 <printnum+0x44>
  80048f:	77 07                	ja     800498 <printnum+0x38>
  800491:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800494:	39 d0                	cmp    %edx,%eax
  800496:	76 0c                	jbe    8004a4 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800498:	83 eb 01             	sub    $0x1,%ebx
  80049b:	85 db                	test   %ebx,%ebx
  80049d:	8d 76 00             	lea    0x0(%esi),%esi
  8004a0:	7f 61                	jg     800503 <printnum+0xa3>
  8004a2:	eb 70                	jmp    800514 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  8004a4:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8004a8:	83 eb 01             	sub    $0x1,%ebx
  8004ab:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8004af:	89 44 24 08          	mov    %eax,0x8(%esp)
  8004b3:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  8004b7:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  8004bb:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  8004be:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  8004c1:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8004c4:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8004c8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8004cf:	00 
  8004d0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8004d3:	89 04 24             	mov    %eax,(%esp)
  8004d6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8004d9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8004dd:	e8 ae 27 00 00       	call   802c90 <__udivdi3>
  8004e2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8004e5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8004e8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8004ec:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8004f0:	89 04 24             	mov    %eax,(%esp)
  8004f3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8004f7:	89 f2                	mov    %esi,%edx
  8004f9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8004fc:	e8 5f ff ff ff       	call   800460 <printnum>
  800501:	eb 11                	jmp    800514 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  800503:	89 74 24 04          	mov    %esi,0x4(%esp)
  800507:	89 3c 24             	mov    %edi,(%esp)
  80050a:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  80050d:	83 eb 01             	sub    $0x1,%ebx
  800510:	85 db                	test   %ebx,%ebx
  800512:	7f ef                	jg     800503 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  800514:	89 74 24 04          	mov    %esi,0x4(%esp)
  800518:	8b 74 24 04          	mov    0x4(%esp),%esi
  80051c:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80051f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800523:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80052a:	00 
  80052b:	8b 55 d8             	mov    -0x28(%ebp),%edx
  80052e:	89 14 24             	mov    %edx,(%esp)
  800531:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800534:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800538:	e8 83 28 00 00       	call   802dc0 <__umoddi3>
  80053d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800541:	0f be 80 e4 2f 80 00 	movsbl 0x802fe4(%eax),%eax
  800548:	89 04 24             	mov    %eax,(%esp)
  80054b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80054e:	83 c4 4c             	add    $0x4c,%esp
  800551:	5b                   	pop    %ebx
  800552:	5e                   	pop    %esi
  800553:	5f                   	pop    %edi
  800554:	5d                   	pop    %ebp
  800555:	c3                   	ret    

00800556 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800556:	55                   	push   %ebp
  800557:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800559:	83 fa 01             	cmp    $0x1,%edx
  80055c:	7e 0e                	jle    80056c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80055e:	8b 10                	mov    (%eax),%edx
  800560:	8d 4a 08             	lea    0x8(%edx),%ecx
  800563:	89 08                	mov    %ecx,(%eax)
  800565:	8b 02                	mov    (%edx),%eax
  800567:	8b 52 04             	mov    0x4(%edx),%edx
  80056a:	eb 22                	jmp    80058e <getuint+0x38>
	else if (lflag)
  80056c:	85 d2                	test   %edx,%edx
  80056e:	74 10                	je     800580 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800570:	8b 10                	mov    (%eax),%edx
  800572:	8d 4a 04             	lea    0x4(%edx),%ecx
  800575:	89 08                	mov    %ecx,(%eax)
  800577:	8b 02                	mov    (%edx),%eax
  800579:	ba 00 00 00 00       	mov    $0x0,%edx
  80057e:	eb 0e                	jmp    80058e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800580:	8b 10                	mov    (%eax),%edx
  800582:	8d 4a 04             	lea    0x4(%edx),%ecx
  800585:	89 08                	mov    %ecx,(%eax)
  800587:	8b 02                	mov    (%edx),%eax
  800589:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80058e:	5d                   	pop    %ebp
  80058f:	c3                   	ret    

00800590 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800590:	55                   	push   %ebp
  800591:	89 e5                	mov    %esp,%ebp
  800593:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800596:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80059a:	8b 10                	mov    (%eax),%edx
  80059c:	3b 50 04             	cmp    0x4(%eax),%edx
  80059f:	73 0a                	jae    8005ab <sprintputch+0x1b>
		*b->buf++ = ch;
  8005a1:	8b 4d 08             	mov    0x8(%ebp),%ecx
  8005a4:	88 0a                	mov    %cl,(%edx)
  8005a6:	83 c2 01             	add    $0x1,%edx
  8005a9:	89 10                	mov    %edx,(%eax)
}
  8005ab:	5d                   	pop    %ebp
  8005ac:	c3                   	ret    

008005ad <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  8005ad:	55                   	push   %ebp
  8005ae:	89 e5                	mov    %esp,%ebp
  8005b0:	57                   	push   %edi
  8005b1:	56                   	push   %esi
  8005b2:	53                   	push   %ebx
  8005b3:	83 ec 5c             	sub    $0x5c,%esp
  8005b6:	8b 7d 08             	mov    0x8(%ebp),%edi
  8005b9:	8b 75 0c             	mov    0xc(%ebp),%esi
  8005bc:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  8005bf:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  8005c6:	eb 11                	jmp    8005d9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  8005c8:	85 c0                	test   %eax,%eax
  8005ca:	0f 84 f9 03 00 00    	je     8009c9 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8005d0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005d4:	89 04 24             	mov    %eax,(%esp)
  8005d7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8005d9:	0f b6 03             	movzbl (%ebx),%eax
  8005dc:	83 c3 01             	add    $0x1,%ebx
  8005df:	83 f8 25             	cmp    $0x25,%eax
  8005e2:	75 e4                	jne    8005c8 <vprintfmt+0x1b>
  8005e4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8005e8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8005ef:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8005f6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8005fd:	b9 00 00 00 00       	mov    $0x0,%ecx
  800602:	eb 06                	jmp    80060a <vprintfmt+0x5d>
  800604:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  800608:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  80060a:	0f b6 13             	movzbl (%ebx),%edx
  80060d:	0f b6 c2             	movzbl %dl,%eax
  800610:	89 45 e0             	mov    %eax,-0x20(%ebp)
  800613:	8d 43 01             	lea    0x1(%ebx),%eax
  800616:	83 ea 23             	sub    $0x23,%edx
  800619:	80 fa 55             	cmp    $0x55,%dl
  80061c:	0f 87 8a 03 00 00    	ja     8009ac <vprintfmt+0x3ff>
  800622:	0f b6 d2             	movzbl %dl,%edx
  800625:	ff 24 95 20 31 80 00 	jmp    *0x803120(,%edx,4)
  80062c:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800630:	eb d6                	jmp    800608 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800632:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800635:	83 ea 30             	sub    $0x30,%edx
  800638:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80063b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80063e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800641:	83 fb 09             	cmp    $0x9,%ebx
  800644:	77 54                	ja     80069a <vprintfmt+0xed>
  800646:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800649:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80064c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80064f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800652:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800656:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800659:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80065c:	83 fb 09             	cmp    $0x9,%ebx
  80065f:	76 eb                	jbe    80064c <vprintfmt+0x9f>
  800661:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800664:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800667:	eb 31                	jmp    80069a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800669:	8b 55 14             	mov    0x14(%ebp),%edx
  80066c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80066f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800672:	8b 12                	mov    (%edx),%edx
  800674:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800677:	eb 21                	jmp    80069a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800679:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80067d:	ba 00 00 00 00       	mov    $0x0,%edx
  800682:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800686:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800689:	e9 7a ff ff ff       	jmp    800608 <vprintfmt+0x5b>
  80068e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800695:	e9 6e ff ff ff       	jmp    800608 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80069a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80069e:	0f 89 64 ff ff ff    	jns    800608 <vprintfmt+0x5b>
  8006a4:	8b 55 d0             	mov    -0x30(%ebp),%edx
  8006a7:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8006aa:	8b 55 c8             	mov    -0x38(%ebp),%edx
  8006ad:	89 55 d0             	mov    %edx,-0x30(%ebp)
  8006b0:	e9 53 ff ff ff       	jmp    800608 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  8006b5:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  8006b8:	e9 4b ff ff ff       	jmp    800608 <vprintfmt+0x5b>
  8006bd:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  8006c0:	8b 45 14             	mov    0x14(%ebp),%eax
  8006c3:	8d 50 04             	lea    0x4(%eax),%edx
  8006c6:	89 55 14             	mov    %edx,0x14(%ebp)
  8006c9:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006cd:	8b 00                	mov    (%eax),%eax
  8006cf:	89 04 24             	mov    %eax,(%esp)
  8006d2:	ff d7                	call   *%edi
  8006d4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8006d7:	e9 fd fe ff ff       	jmp    8005d9 <vprintfmt+0x2c>
  8006dc:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8006df:	8b 45 14             	mov    0x14(%ebp),%eax
  8006e2:	8d 50 04             	lea    0x4(%eax),%edx
  8006e5:	89 55 14             	mov    %edx,0x14(%ebp)
  8006e8:	8b 00                	mov    (%eax),%eax
  8006ea:	89 c2                	mov    %eax,%edx
  8006ec:	c1 fa 1f             	sar    $0x1f,%edx
  8006ef:	31 d0                	xor    %edx,%eax
  8006f1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8006f3:	83 f8 12             	cmp    $0x12,%eax
  8006f6:	7f 0b                	jg     800703 <vprintfmt+0x156>
  8006f8:	8b 14 85 80 32 80 00 	mov    0x803280(,%eax,4),%edx
  8006ff:	85 d2                	test   %edx,%edx
  800701:	75 20                	jne    800723 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  800703:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800707:	c7 44 24 08 f5 2f 80 	movl   $0x802ff5,0x8(%esp)
  80070e:	00 
  80070f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800713:	89 3c 24             	mov    %edi,(%esp)
  800716:	e8 36 03 00 00       	call   800a51 <printfmt>
  80071b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  80071e:	e9 b6 fe ff ff       	jmp    8005d9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  800723:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800727:	c7 44 24 08 92 35 80 	movl   $0x803592,0x8(%esp)
  80072e:	00 
  80072f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800733:	89 3c 24             	mov    %edi,(%esp)
  800736:	e8 16 03 00 00       	call   800a51 <printfmt>
  80073b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80073e:	e9 96 fe ff ff       	jmp    8005d9 <vprintfmt+0x2c>
  800743:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800746:	89 c3                	mov    %eax,%ebx
  800748:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80074b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80074e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800751:	8b 45 14             	mov    0x14(%ebp),%eax
  800754:	8d 50 04             	lea    0x4(%eax),%edx
  800757:	89 55 14             	mov    %edx,0x14(%ebp)
  80075a:	8b 00                	mov    (%eax),%eax
  80075c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80075f:	85 c0                	test   %eax,%eax
  800761:	b8 fe 2f 80 00       	mov    $0x802ffe,%eax
  800766:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80076a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80076d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800771:	7e 06                	jle    800779 <vprintfmt+0x1cc>
  800773:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800777:	75 13                	jne    80078c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800779:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80077c:	0f be 02             	movsbl (%edx),%eax
  80077f:	85 c0                	test   %eax,%eax
  800781:	0f 85 9b 00 00 00    	jne    800822 <vprintfmt+0x275>
  800787:	e9 88 00 00 00       	jmp    800814 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80078c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800790:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800793:	89 0c 24             	mov    %ecx,(%esp)
  800796:	e8 00 03 00 00       	call   800a9b <strnlen>
  80079b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80079e:	29 c2                	sub    %eax,%edx
  8007a0:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8007a3:	85 d2                	test   %edx,%edx
  8007a5:	7e d2                	jle    800779 <vprintfmt+0x1cc>
					putch(padc, putdat);
  8007a7:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  8007ab:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  8007ae:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  8007b1:	89 d3                	mov    %edx,%ebx
  8007b3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007b7:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8007ba:	89 04 24             	mov    %eax,(%esp)
  8007bd:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  8007bf:	83 eb 01             	sub    $0x1,%ebx
  8007c2:	85 db                	test   %ebx,%ebx
  8007c4:	7f ed                	jg     8007b3 <vprintfmt+0x206>
  8007c6:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  8007c9:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8007d0:	eb a7                	jmp    800779 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8007d2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8007d6:	74 1a                	je     8007f2 <vprintfmt+0x245>
  8007d8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8007db:	83 fa 5e             	cmp    $0x5e,%edx
  8007de:	76 12                	jbe    8007f2 <vprintfmt+0x245>
					putch('?', putdat);
  8007e0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8007e4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8007eb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8007ee:	66 90                	xchg   %ax,%ax
  8007f0:	eb 0a                	jmp    8007fc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8007f2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8007f6:	89 04 24             	mov    %eax,(%esp)
  8007f9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8007fc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  800800:	0f be 03             	movsbl (%ebx),%eax
  800803:	85 c0                	test   %eax,%eax
  800805:	74 05                	je     80080c <vprintfmt+0x25f>
  800807:	83 c3 01             	add    $0x1,%ebx
  80080a:	eb 29                	jmp    800835 <vprintfmt+0x288>
  80080c:	89 fe                	mov    %edi,%esi
  80080e:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800811:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  800814:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  800818:	7f 2e                	jg     800848 <vprintfmt+0x29b>
  80081a:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80081d:	e9 b7 fd ff ff       	jmp    8005d9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800822:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800825:	83 c2 01             	add    $0x1,%edx
  800828:	89 7d e0             	mov    %edi,-0x20(%ebp)
  80082b:	89 f7                	mov    %esi,%edi
  80082d:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800830:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800833:	89 d3                	mov    %edx,%ebx
  800835:	85 f6                	test   %esi,%esi
  800837:	78 99                	js     8007d2 <vprintfmt+0x225>
  800839:	83 ee 01             	sub    $0x1,%esi
  80083c:	79 94                	jns    8007d2 <vprintfmt+0x225>
  80083e:	89 fe                	mov    %edi,%esi
  800840:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800843:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800846:	eb cc                	jmp    800814 <vprintfmt+0x267>
  800848:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80084b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80084e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800852:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800859:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80085b:	83 eb 01             	sub    $0x1,%ebx
  80085e:	85 db                	test   %ebx,%ebx
  800860:	7f ec                	jg     80084e <vprintfmt+0x2a1>
  800862:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800865:	e9 6f fd ff ff       	jmp    8005d9 <vprintfmt+0x2c>
  80086a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80086d:	83 f9 01             	cmp    $0x1,%ecx
  800870:	7e 16                	jle    800888 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800872:	8b 45 14             	mov    0x14(%ebp),%eax
  800875:	8d 50 08             	lea    0x8(%eax),%edx
  800878:	89 55 14             	mov    %edx,0x14(%ebp)
  80087b:	8b 10                	mov    (%eax),%edx
  80087d:	8b 48 04             	mov    0x4(%eax),%ecx
  800880:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800883:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800886:	eb 32                	jmp    8008ba <vprintfmt+0x30d>
	else if (lflag)
  800888:	85 c9                	test   %ecx,%ecx
  80088a:	74 18                	je     8008a4 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80088c:	8b 45 14             	mov    0x14(%ebp),%eax
  80088f:	8d 50 04             	lea    0x4(%eax),%edx
  800892:	89 55 14             	mov    %edx,0x14(%ebp)
  800895:	8b 00                	mov    (%eax),%eax
  800897:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80089a:	89 c1                	mov    %eax,%ecx
  80089c:	c1 f9 1f             	sar    $0x1f,%ecx
  80089f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  8008a2:	eb 16                	jmp    8008ba <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  8008a4:	8b 45 14             	mov    0x14(%ebp),%eax
  8008a7:	8d 50 04             	lea    0x4(%eax),%edx
  8008aa:	89 55 14             	mov    %edx,0x14(%ebp)
  8008ad:	8b 00                	mov    (%eax),%eax
  8008af:	89 45 d8             	mov    %eax,-0x28(%ebp)
  8008b2:	89 c2                	mov    %eax,%edx
  8008b4:	c1 fa 1f             	sar    $0x1f,%edx
  8008b7:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  8008ba:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8008bd:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8008c0:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  8008c5:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  8008c9:	0f 89 9b 00 00 00    	jns    80096a <vprintfmt+0x3bd>
				putch('-', putdat);
  8008cf:	89 74 24 04          	mov    %esi,0x4(%esp)
  8008d3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8008da:	ff d7                	call   *%edi
				num = -(long long) num;
  8008dc:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8008df:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8008e2:	f7 d9                	neg    %ecx
  8008e4:	83 d3 00             	adc    $0x0,%ebx
  8008e7:	f7 db                	neg    %ebx
  8008e9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8008ee:	eb 7a                	jmp    80096a <vprintfmt+0x3bd>
  8008f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8008f3:	89 ca                	mov    %ecx,%edx
  8008f5:	8d 45 14             	lea    0x14(%ebp),%eax
  8008f8:	e8 59 fc ff ff       	call   800556 <getuint>
  8008fd:	89 c1                	mov    %eax,%ecx
  8008ff:	89 d3                	mov    %edx,%ebx
  800901:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  800906:	eb 62                	jmp    80096a <vprintfmt+0x3bd>
  800908:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  80090b:	89 ca                	mov    %ecx,%edx
  80090d:	8d 45 14             	lea    0x14(%ebp),%eax
  800910:	e8 41 fc ff ff       	call   800556 <getuint>
  800915:	89 c1                	mov    %eax,%ecx
  800917:	89 d3                	mov    %edx,%ebx
  800919:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  80091e:	eb 4a                	jmp    80096a <vprintfmt+0x3bd>
  800920:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  800923:	89 74 24 04          	mov    %esi,0x4(%esp)
  800927:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  80092e:	ff d7                	call   *%edi
			putch('x', putdat);
  800930:	89 74 24 04          	mov    %esi,0x4(%esp)
  800934:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80093b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80093d:	8b 45 14             	mov    0x14(%ebp),%eax
  800940:	8d 50 04             	lea    0x4(%eax),%edx
  800943:	89 55 14             	mov    %edx,0x14(%ebp)
  800946:	8b 08                	mov    (%eax),%ecx
  800948:	bb 00 00 00 00       	mov    $0x0,%ebx
  80094d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800952:	eb 16                	jmp    80096a <vprintfmt+0x3bd>
  800954:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800957:	89 ca                	mov    %ecx,%edx
  800959:	8d 45 14             	lea    0x14(%ebp),%eax
  80095c:	e8 f5 fb ff ff       	call   800556 <getuint>
  800961:	89 c1                	mov    %eax,%ecx
  800963:	89 d3                	mov    %edx,%ebx
  800965:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80096a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80096e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800972:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800975:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800979:	89 44 24 08          	mov    %eax,0x8(%esp)
  80097d:	89 0c 24             	mov    %ecx,(%esp)
  800980:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800984:	89 f2                	mov    %esi,%edx
  800986:	89 f8                	mov    %edi,%eax
  800988:	e8 d3 fa ff ff       	call   800460 <printnum>
  80098d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800990:	e9 44 fc ff ff       	jmp    8005d9 <vprintfmt+0x2c>
  800995:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800998:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80099b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80099f:	89 14 24             	mov    %edx,(%esp)
  8009a2:	ff d7                	call   *%edi
  8009a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8009a7:	e9 2d fc ff ff       	jmp    8005d9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  8009ac:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009b0:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  8009b7:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  8009b9:	8d 43 ff             	lea    -0x1(%ebx),%eax
  8009bc:	80 38 25             	cmpb   $0x25,(%eax)
  8009bf:	0f 84 14 fc ff ff    	je     8005d9 <vprintfmt+0x2c>
  8009c5:	89 c3                	mov    %eax,%ebx
  8009c7:	eb f0                	jmp    8009b9 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  8009c9:	83 c4 5c             	add    $0x5c,%esp
  8009cc:	5b                   	pop    %ebx
  8009cd:	5e                   	pop    %esi
  8009ce:	5f                   	pop    %edi
  8009cf:	5d                   	pop    %ebp
  8009d0:	c3                   	ret    

008009d1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8009d1:	55                   	push   %ebp
  8009d2:	89 e5                	mov    %esp,%ebp
  8009d4:	83 ec 28             	sub    $0x28,%esp
  8009d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8009da:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8009dd:	85 c0                	test   %eax,%eax
  8009df:	74 04                	je     8009e5 <vsnprintf+0x14>
  8009e1:	85 d2                	test   %edx,%edx
  8009e3:	7f 07                	jg     8009ec <vsnprintf+0x1b>
  8009e5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8009ea:	eb 3b                	jmp    800a27 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8009ec:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8009ef:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8009f3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8009f6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8009fd:	8b 45 14             	mov    0x14(%ebp),%eax
  800a00:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a04:	8b 45 10             	mov    0x10(%ebp),%eax
  800a07:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a0b:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800a0e:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a12:	c7 04 24 90 05 80 00 	movl   $0x800590,(%esp)
  800a19:	e8 8f fb ff ff       	call   8005ad <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800a1e:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800a21:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800a24:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800a27:	c9                   	leave  
  800a28:	c3                   	ret    

00800a29 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800a29:	55                   	push   %ebp
  800a2a:	89 e5                	mov    %esp,%ebp
  800a2c:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800a2f:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800a32:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a36:	8b 45 10             	mov    0x10(%ebp),%eax
  800a39:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a3d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800a40:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a44:	8b 45 08             	mov    0x8(%ebp),%eax
  800a47:	89 04 24             	mov    %eax,(%esp)
  800a4a:	e8 82 ff ff ff       	call   8009d1 <vsnprintf>
	va_end(ap);

	return rc;
}
  800a4f:	c9                   	leave  
  800a50:	c3                   	ret    

00800a51 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800a51:	55                   	push   %ebp
  800a52:	89 e5                	mov    %esp,%ebp
  800a54:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800a57:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800a5a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800a5e:	8b 45 10             	mov    0x10(%ebp),%eax
  800a61:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a65:	8b 45 0c             	mov    0xc(%ebp),%eax
  800a68:	89 44 24 04          	mov    %eax,0x4(%esp)
  800a6c:	8b 45 08             	mov    0x8(%ebp),%eax
  800a6f:	89 04 24             	mov    %eax,(%esp)
  800a72:	e8 36 fb ff ff       	call   8005ad <vprintfmt>
	va_end(ap);
}
  800a77:	c9                   	leave  
  800a78:	c3                   	ret    
  800a79:	00 00                	add    %al,(%eax)
  800a7b:	00 00                	add    %al,(%eax)
  800a7d:	00 00                	add    %al,(%eax)
	...

00800a80 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800a80:	55                   	push   %ebp
  800a81:	89 e5                	mov    %esp,%ebp
  800a83:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800a86:	b8 00 00 00 00       	mov    $0x0,%eax
  800a8b:	80 3a 00             	cmpb   $0x0,(%edx)
  800a8e:	74 09                	je     800a99 <strlen+0x19>
		n++;
  800a90:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800a93:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800a97:	75 f7                	jne    800a90 <strlen+0x10>
		n++;
	return n;
}
  800a99:	5d                   	pop    %ebp
  800a9a:	c3                   	ret    

00800a9b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800a9b:	55                   	push   %ebp
  800a9c:	89 e5                	mov    %esp,%ebp
  800a9e:	53                   	push   %ebx
  800a9f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800aa2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800aa5:	85 c9                	test   %ecx,%ecx
  800aa7:	74 19                	je     800ac2 <strnlen+0x27>
  800aa9:	80 3b 00             	cmpb   $0x0,(%ebx)
  800aac:	74 14                	je     800ac2 <strnlen+0x27>
  800aae:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800ab3:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800ab6:	39 c8                	cmp    %ecx,%eax
  800ab8:	74 0d                	je     800ac7 <strnlen+0x2c>
  800aba:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800abe:	75 f3                	jne    800ab3 <strnlen+0x18>
  800ac0:	eb 05                	jmp    800ac7 <strnlen+0x2c>
  800ac2:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800ac7:	5b                   	pop    %ebx
  800ac8:	5d                   	pop    %ebp
  800ac9:	c3                   	ret    

00800aca <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800aca:	55                   	push   %ebp
  800acb:	89 e5                	mov    %esp,%ebp
  800acd:	53                   	push   %ebx
  800ace:	8b 45 08             	mov    0x8(%ebp),%eax
  800ad1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800ad4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800ad9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800add:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800ae0:	83 c2 01             	add    $0x1,%edx
  800ae3:	84 c9                	test   %cl,%cl
  800ae5:	75 f2                	jne    800ad9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800ae7:	5b                   	pop    %ebx
  800ae8:	5d                   	pop    %ebp
  800ae9:	c3                   	ret    

00800aea <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800aea:	55                   	push   %ebp
  800aeb:	89 e5                	mov    %esp,%ebp
  800aed:	56                   	push   %esi
  800aee:	53                   	push   %ebx
  800aef:	8b 45 08             	mov    0x8(%ebp),%eax
  800af2:	8b 55 0c             	mov    0xc(%ebp),%edx
  800af5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800af8:	85 f6                	test   %esi,%esi
  800afa:	74 18                	je     800b14 <strncpy+0x2a>
  800afc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800b01:	0f b6 1a             	movzbl (%edx),%ebx
  800b04:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800b07:	80 3a 01             	cmpb   $0x1,(%edx)
  800b0a:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800b0d:	83 c1 01             	add    $0x1,%ecx
  800b10:	39 ce                	cmp    %ecx,%esi
  800b12:	77 ed                	ja     800b01 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800b14:	5b                   	pop    %ebx
  800b15:	5e                   	pop    %esi
  800b16:	5d                   	pop    %ebp
  800b17:	c3                   	ret    

00800b18 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800b18:	55                   	push   %ebp
  800b19:	89 e5                	mov    %esp,%ebp
  800b1b:	56                   	push   %esi
  800b1c:	53                   	push   %ebx
  800b1d:	8b 75 08             	mov    0x8(%ebp),%esi
  800b20:	8b 55 0c             	mov    0xc(%ebp),%edx
  800b23:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800b26:	89 f0                	mov    %esi,%eax
  800b28:	85 c9                	test   %ecx,%ecx
  800b2a:	74 27                	je     800b53 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800b2c:	83 e9 01             	sub    $0x1,%ecx
  800b2f:	74 1d                	je     800b4e <strlcpy+0x36>
  800b31:	0f b6 1a             	movzbl (%edx),%ebx
  800b34:	84 db                	test   %bl,%bl
  800b36:	74 16                	je     800b4e <strlcpy+0x36>
			*dst++ = *src++;
  800b38:	88 18                	mov    %bl,(%eax)
  800b3a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800b3d:	83 e9 01             	sub    $0x1,%ecx
  800b40:	74 0e                	je     800b50 <strlcpy+0x38>
			*dst++ = *src++;
  800b42:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800b45:	0f b6 1a             	movzbl (%edx),%ebx
  800b48:	84 db                	test   %bl,%bl
  800b4a:	75 ec                	jne    800b38 <strlcpy+0x20>
  800b4c:	eb 02                	jmp    800b50 <strlcpy+0x38>
  800b4e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800b50:	c6 00 00             	movb   $0x0,(%eax)
  800b53:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800b55:	5b                   	pop    %ebx
  800b56:	5e                   	pop    %esi
  800b57:	5d                   	pop    %ebp
  800b58:	c3                   	ret    

00800b59 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800b59:	55                   	push   %ebp
  800b5a:	89 e5                	mov    %esp,%ebp
  800b5c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800b5f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800b62:	0f b6 01             	movzbl (%ecx),%eax
  800b65:	84 c0                	test   %al,%al
  800b67:	74 15                	je     800b7e <strcmp+0x25>
  800b69:	3a 02                	cmp    (%edx),%al
  800b6b:	75 11                	jne    800b7e <strcmp+0x25>
		p++, q++;
  800b6d:	83 c1 01             	add    $0x1,%ecx
  800b70:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800b73:	0f b6 01             	movzbl (%ecx),%eax
  800b76:	84 c0                	test   %al,%al
  800b78:	74 04                	je     800b7e <strcmp+0x25>
  800b7a:	3a 02                	cmp    (%edx),%al
  800b7c:	74 ef                	je     800b6d <strcmp+0x14>
  800b7e:	0f b6 c0             	movzbl %al,%eax
  800b81:	0f b6 12             	movzbl (%edx),%edx
  800b84:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800b86:	5d                   	pop    %ebp
  800b87:	c3                   	ret    

00800b88 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800b88:	55                   	push   %ebp
  800b89:	89 e5                	mov    %esp,%ebp
  800b8b:	53                   	push   %ebx
  800b8c:	8b 55 08             	mov    0x8(%ebp),%edx
  800b8f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800b92:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800b95:	85 c0                	test   %eax,%eax
  800b97:	74 23                	je     800bbc <strncmp+0x34>
  800b99:	0f b6 1a             	movzbl (%edx),%ebx
  800b9c:	84 db                	test   %bl,%bl
  800b9e:	74 24                	je     800bc4 <strncmp+0x3c>
  800ba0:	3a 19                	cmp    (%ecx),%bl
  800ba2:	75 20                	jne    800bc4 <strncmp+0x3c>
  800ba4:	83 e8 01             	sub    $0x1,%eax
  800ba7:	74 13                	je     800bbc <strncmp+0x34>
		n--, p++, q++;
  800ba9:	83 c2 01             	add    $0x1,%edx
  800bac:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800baf:	0f b6 1a             	movzbl (%edx),%ebx
  800bb2:	84 db                	test   %bl,%bl
  800bb4:	74 0e                	je     800bc4 <strncmp+0x3c>
  800bb6:	3a 19                	cmp    (%ecx),%bl
  800bb8:	74 ea                	je     800ba4 <strncmp+0x1c>
  800bba:	eb 08                	jmp    800bc4 <strncmp+0x3c>
  800bbc:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800bc1:	5b                   	pop    %ebx
  800bc2:	5d                   	pop    %ebp
  800bc3:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800bc4:	0f b6 02             	movzbl (%edx),%eax
  800bc7:	0f b6 11             	movzbl (%ecx),%edx
  800bca:	29 d0                	sub    %edx,%eax
  800bcc:	eb f3                	jmp    800bc1 <strncmp+0x39>

00800bce <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800bce:	55                   	push   %ebp
  800bcf:	89 e5                	mov    %esp,%ebp
  800bd1:	8b 45 08             	mov    0x8(%ebp),%eax
  800bd4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800bd8:	0f b6 10             	movzbl (%eax),%edx
  800bdb:	84 d2                	test   %dl,%dl
  800bdd:	74 15                	je     800bf4 <strchr+0x26>
		if (*s == c)
  800bdf:	38 ca                	cmp    %cl,%dl
  800be1:	75 07                	jne    800bea <strchr+0x1c>
  800be3:	eb 14                	jmp    800bf9 <strchr+0x2b>
  800be5:	38 ca                	cmp    %cl,%dl
  800be7:	90                   	nop
  800be8:	74 0f                	je     800bf9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800bea:	83 c0 01             	add    $0x1,%eax
  800bed:	0f b6 10             	movzbl (%eax),%edx
  800bf0:	84 d2                	test   %dl,%dl
  800bf2:	75 f1                	jne    800be5 <strchr+0x17>
  800bf4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800bf9:	5d                   	pop    %ebp
  800bfa:	c3                   	ret    

00800bfb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800bfb:	55                   	push   %ebp
  800bfc:	89 e5                	mov    %esp,%ebp
  800bfe:	8b 45 08             	mov    0x8(%ebp),%eax
  800c01:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800c05:	0f b6 10             	movzbl (%eax),%edx
  800c08:	84 d2                	test   %dl,%dl
  800c0a:	74 18                	je     800c24 <strfind+0x29>
		if (*s == c)
  800c0c:	38 ca                	cmp    %cl,%dl
  800c0e:	75 0a                	jne    800c1a <strfind+0x1f>
  800c10:	eb 12                	jmp    800c24 <strfind+0x29>
  800c12:	38 ca                	cmp    %cl,%dl
  800c14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800c18:	74 0a                	je     800c24 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800c1a:	83 c0 01             	add    $0x1,%eax
  800c1d:	0f b6 10             	movzbl (%eax),%edx
  800c20:	84 d2                	test   %dl,%dl
  800c22:	75 ee                	jne    800c12 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800c24:	5d                   	pop    %ebp
  800c25:	c3                   	ret    

00800c26 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800c26:	55                   	push   %ebp
  800c27:	89 e5                	mov    %esp,%ebp
  800c29:	83 ec 0c             	sub    $0xc,%esp
  800c2c:	89 1c 24             	mov    %ebx,(%esp)
  800c2f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c33:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800c37:	8b 7d 08             	mov    0x8(%ebp),%edi
  800c3a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800c3d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800c40:	85 c9                	test   %ecx,%ecx
  800c42:	74 30                	je     800c74 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800c44:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800c4a:	75 25                	jne    800c71 <memset+0x4b>
  800c4c:	f6 c1 03             	test   $0x3,%cl
  800c4f:	75 20                	jne    800c71 <memset+0x4b>
		c &= 0xFF;
  800c51:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800c54:	89 d3                	mov    %edx,%ebx
  800c56:	c1 e3 08             	shl    $0x8,%ebx
  800c59:	89 d6                	mov    %edx,%esi
  800c5b:	c1 e6 18             	shl    $0x18,%esi
  800c5e:	89 d0                	mov    %edx,%eax
  800c60:	c1 e0 10             	shl    $0x10,%eax
  800c63:	09 f0                	or     %esi,%eax
  800c65:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800c67:	09 d8                	or     %ebx,%eax
  800c69:	c1 e9 02             	shr    $0x2,%ecx
  800c6c:	fc                   	cld    
  800c6d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800c6f:	eb 03                	jmp    800c74 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800c71:	fc                   	cld    
  800c72:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800c74:	89 f8                	mov    %edi,%eax
  800c76:	8b 1c 24             	mov    (%esp),%ebx
  800c79:	8b 74 24 04          	mov    0x4(%esp),%esi
  800c7d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800c81:	89 ec                	mov    %ebp,%esp
  800c83:	5d                   	pop    %ebp
  800c84:	c3                   	ret    

00800c85 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800c85:	55                   	push   %ebp
  800c86:	89 e5                	mov    %esp,%ebp
  800c88:	83 ec 08             	sub    $0x8,%esp
  800c8b:	89 34 24             	mov    %esi,(%esp)
  800c8e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800c92:	8b 45 08             	mov    0x8(%ebp),%eax
  800c95:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800c98:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800c9b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800c9d:	39 c6                	cmp    %eax,%esi
  800c9f:	73 35                	jae    800cd6 <memmove+0x51>
  800ca1:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800ca4:	39 d0                	cmp    %edx,%eax
  800ca6:	73 2e                	jae    800cd6 <memmove+0x51>
		s += n;
		d += n;
  800ca8:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800caa:	f6 c2 03             	test   $0x3,%dl
  800cad:	75 1b                	jne    800cca <memmove+0x45>
  800caf:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800cb5:	75 13                	jne    800cca <memmove+0x45>
  800cb7:	f6 c1 03             	test   $0x3,%cl
  800cba:	75 0e                	jne    800cca <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800cbc:	83 ef 04             	sub    $0x4,%edi
  800cbf:	8d 72 fc             	lea    -0x4(%edx),%esi
  800cc2:	c1 e9 02             	shr    $0x2,%ecx
  800cc5:	fd                   	std    
  800cc6:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800cc8:	eb 09                	jmp    800cd3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800cca:	83 ef 01             	sub    $0x1,%edi
  800ccd:	8d 72 ff             	lea    -0x1(%edx),%esi
  800cd0:	fd                   	std    
  800cd1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800cd3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800cd4:	eb 20                	jmp    800cf6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800cd6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800cdc:	75 15                	jne    800cf3 <memmove+0x6e>
  800cde:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800ce4:	75 0d                	jne    800cf3 <memmove+0x6e>
  800ce6:	f6 c1 03             	test   $0x3,%cl
  800ce9:	75 08                	jne    800cf3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800ceb:	c1 e9 02             	shr    $0x2,%ecx
  800cee:	fc                   	cld    
  800cef:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800cf1:	eb 03                	jmp    800cf6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800cf3:	fc                   	cld    
  800cf4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800cf6:	8b 34 24             	mov    (%esp),%esi
  800cf9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800cfd:	89 ec                	mov    %ebp,%esp
  800cff:	5d                   	pop    %ebp
  800d00:	c3                   	ret    

00800d01 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800d01:	55                   	push   %ebp
  800d02:	89 e5                	mov    %esp,%ebp
  800d04:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800d07:	8b 45 10             	mov    0x10(%ebp),%eax
  800d0a:	89 44 24 08          	mov    %eax,0x8(%esp)
  800d0e:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d11:	89 44 24 04          	mov    %eax,0x4(%esp)
  800d15:	8b 45 08             	mov    0x8(%ebp),%eax
  800d18:	89 04 24             	mov    %eax,(%esp)
  800d1b:	e8 65 ff ff ff       	call   800c85 <memmove>
}
  800d20:	c9                   	leave  
  800d21:	c3                   	ret    

00800d22 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800d22:	55                   	push   %ebp
  800d23:	89 e5                	mov    %esp,%ebp
  800d25:	57                   	push   %edi
  800d26:	56                   	push   %esi
  800d27:	53                   	push   %ebx
  800d28:	8b 75 08             	mov    0x8(%ebp),%esi
  800d2b:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800d2e:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800d31:	85 c9                	test   %ecx,%ecx
  800d33:	74 36                	je     800d6b <memcmp+0x49>
		if (*s1 != *s2)
  800d35:	0f b6 06             	movzbl (%esi),%eax
  800d38:	0f b6 1f             	movzbl (%edi),%ebx
  800d3b:	38 d8                	cmp    %bl,%al
  800d3d:	74 20                	je     800d5f <memcmp+0x3d>
  800d3f:	eb 14                	jmp    800d55 <memcmp+0x33>
  800d41:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800d46:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800d4b:	83 c2 01             	add    $0x1,%edx
  800d4e:	83 e9 01             	sub    $0x1,%ecx
  800d51:	38 d8                	cmp    %bl,%al
  800d53:	74 12                	je     800d67 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800d55:	0f b6 c0             	movzbl %al,%eax
  800d58:	0f b6 db             	movzbl %bl,%ebx
  800d5b:	29 d8                	sub    %ebx,%eax
  800d5d:	eb 11                	jmp    800d70 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800d5f:	83 e9 01             	sub    $0x1,%ecx
  800d62:	ba 00 00 00 00       	mov    $0x0,%edx
  800d67:	85 c9                	test   %ecx,%ecx
  800d69:	75 d6                	jne    800d41 <memcmp+0x1f>
  800d6b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800d70:	5b                   	pop    %ebx
  800d71:	5e                   	pop    %esi
  800d72:	5f                   	pop    %edi
  800d73:	5d                   	pop    %ebp
  800d74:	c3                   	ret    

00800d75 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800d75:	55                   	push   %ebp
  800d76:	89 e5                	mov    %esp,%ebp
  800d78:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800d7b:	89 c2                	mov    %eax,%edx
  800d7d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800d80:	39 d0                	cmp    %edx,%eax
  800d82:	73 15                	jae    800d99 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800d84:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800d88:	38 08                	cmp    %cl,(%eax)
  800d8a:	75 06                	jne    800d92 <memfind+0x1d>
  800d8c:	eb 0b                	jmp    800d99 <memfind+0x24>
  800d8e:	38 08                	cmp    %cl,(%eax)
  800d90:	74 07                	je     800d99 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800d92:	83 c0 01             	add    $0x1,%eax
  800d95:	39 c2                	cmp    %eax,%edx
  800d97:	77 f5                	ja     800d8e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800d99:	5d                   	pop    %ebp
  800d9a:	c3                   	ret    

00800d9b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800d9b:	55                   	push   %ebp
  800d9c:	89 e5                	mov    %esp,%ebp
  800d9e:	57                   	push   %edi
  800d9f:	56                   	push   %esi
  800da0:	53                   	push   %ebx
  800da1:	83 ec 04             	sub    $0x4,%esp
  800da4:	8b 55 08             	mov    0x8(%ebp),%edx
  800da7:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800daa:	0f b6 02             	movzbl (%edx),%eax
  800dad:	3c 20                	cmp    $0x20,%al
  800daf:	74 04                	je     800db5 <strtol+0x1a>
  800db1:	3c 09                	cmp    $0x9,%al
  800db3:	75 0e                	jne    800dc3 <strtol+0x28>
		s++;
  800db5:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800db8:	0f b6 02             	movzbl (%edx),%eax
  800dbb:	3c 20                	cmp    $0x20,%al
  800dbd:	74 f6                	je     800db5 <strtol+0x1a>
  800dbf:	3c 09                	cmp    $0x9,%al
  800dc1:	74 f2                	je     800db5 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800dc3:	3c 2b                	cmp    $0x2b,%al
  800dc5:	75 0c                	jne    800dd3 <strtol+0x38>
		s++;
  800dc7:	83 c2 01             	add    $0x1,%edx
  800dca:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800dd1:	eb 15                	jmp    800de8 <strtol+0x4d>
	else if (*s == '-')
  800dd3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800dda:	3c 2d                	cmp    $0x2d,%al
  800ddc:	75 0a                	jne    800de8 <strtol+0x4d>
		s++, neg = 1;
  800dde:	83 c2 01             	add    $0x1,%edx
  800de1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800de8:	85 db                	test   %ebx,%ebx
  800dea:	0f 94 c0             	sete   %al
  800ded:	74 05                	je     800df4 <strtol+0x59>
  800def:	83 fb 10             	cmp    $0x10,%ebx
  800df2:	75 18                	jne    800e0c <strtol+0x71>
  800df4:	80 3a 30             	cmpb   $0x30,(%edx)
  800df7:	75 13                	jne    800e0c <strtol+0x71>
  800df9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800dfd:	8d 76 00             	lea    0x0(%esi),%esi
  800e00:	75 0a                	jne    800e0c <strtol+0x71>
		s += 2, base = 16;
  800e02:	83 c2 02             	add    $0x2,%edx
  800e05:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800e0a:	eb 15                	jmp    800e21 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800e0c:	84 c0                	test   %al,%al
  800e0e:	66 90                	xchg   %ax,%ax
  800e10:	74 0f                	je     800e21 <strtol+0x86>
  800e12:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800e17:	80 3a 30             	cmpb   $0x30,(%edx)
  800e1a:	75 05                	jne    800e21 <strtol+0x86>
		s++, base = 8;
  800e1c:	83 c2 01             	add    $0x1,%edx
  800e1f:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800e21:	b8 00 00 00 00       	mov    $0x0,%eax
  800e26:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800e28:	0f b6 0a             	movzbl (%edx),%ecx
  800e2b:	89 cf                	mov    %ecx,%edi
  800e2d:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800e30:	80 fb 09             	cmp    $0x9,%bl
  800e33:	77 08                	ja     800e3d <strtol+0xa2>
			dig = *s - '0';
  800e35:	0f be c9             	movsbl %cl,%ecx
  800e38:	83 e9 30             	sub    $0x30,%ecx
  800e3b:	eb 1e                	jmp    800e5b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800e3d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800e40:	80 fb 19             	cmp    $0x19,%bl
  800e43:	77 08                	ja     800e4d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800e45:	0f be c9             	movsbl %cl,%ecx
  800e48:	83 e9 57             	sub    $0x57,%ecx
  800e4b:	eb 0e                	jmp    800e5b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800e4d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800e50:	80 fb 19             	cmp    $0x19,%bl
  800e53:	77 15                	ja     800e6a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800e55:	0f be c9             	movsbl %cl,%ecx
  800e58:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800e5b:	39 f1                	cmp    %esi,%ecx
  800e5d:	7d 0b                	jge    800e6a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800e5f:	83 c2 01             	add    $0x1,%edx
  800e62:	0f af c6             	imul   %esi,%eax
  800e65:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800e68:	eb be                	jmp    800e28 <strtol+0x8d>
  800e6a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800e6c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800e70:	74 05                	je     800e77 <strtol+0xdc>
		*endptr = (char *) s;
  800e72:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800e75:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800e77:	89 ca                	mov    %ecx,%edx
  800e79:	f7 da                	neg    %edx
  800e7b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800e7f:	0f 45 c2             	cmovne %edx,%eax
}
  800e82:	83 c4 04             	add    $0x4,%esp
  800e85:	5b                   	pop    %ebx
  800e86:	5e                   	pop    %esi
  800e87:	5f                   	pop    %edi
  800e88:	5d                   	pop    %ebp
  800e89:	c3                   	ret    
	...

00800e8c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800e8c:	55                   	push   %ebp
  800e8d:	89 e5                	mov    %esp,%ebp
  800e8f:	83 ec 0c             	sub    $0xc,%esp
  800e92:	89 1c 24             	mov    %ebx,(%esp)
  800e95:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e99:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e9d:	ba 00 00 00 00       	mov    $0x0,%edx
  800ea2:	b8 01 00 00 00       	mov    $0x1,%eax
  800ea7:	89 d1                	mov    %edx,%ecx
  800ea9:	89 d3                	mov    %edx,%ebx
  800eab:	89 d7                	mov    %edx,%edi
  800ead:	89 d6                	mov    %edx,%esi
  800eaf:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800eb1:	8b 1c 24             	mov    (%esp),%ebx
  800eb4:	8b 74 24 04          	mov    0x4(%esp),%esi
  800eb8:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800ebc:	89 ec                	mov    %ebp,%esp
  800ebe:	5d                   	pop    %ebp
  800ebf:	c3                   	ret    

00800ec0 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800ec0:	55                   	push   %ebp
  800ec1:	89 e5                	mov    %esp,%ebp
  800ec3:	83 ec 0c             	sub    $0xc,%esp
  800ec6:	89 1c 24             	mov    %ebx,(%esp)
  800ec9:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ecd:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ed1:	b8 00 00 00 00       	mov    $0x0,%eax
  800ed6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ed9:	8b 55 08             	mov    0x8(%ebp),%edx
  800edc:	89 c3                	mov    %eax,%ebx
  800ede:	89 c7                	mov    %eax,%edi
  800ee0:	89 c6                	mov    %eax,%esi
  800ee2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800ee4:	8b 1c 24             	mov    (%esp),%ebx
  800ee7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800eeb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800eef:	89 ec                	mov    %ebp,%esp
  800ef1:	5d                   	pop    %ebp
  800ef2:	c3                   	ret    

00800ef3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800ef3:	55                   	push   %ebp
  800ef4:	89 e5                	mov    %esp,%ebp
  800ef6:	83 ec 0c             	sub    $0xc,%esp
  800ef9:	89 1c 24             	mov    %ebx,(%esp)
  800efc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f00:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f04:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f09:	b8 10 00 00 00       	mov    $0x10,%eax
  800f0e:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f11:	8b 55 08             	mov    0x8(%ebp),%edx
  800f14:	89 df                	mov    %ebx,%edi
  800f16:	89 de                	mov    %ebx,%esi
  800f18:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800f1a:	8b 1c 24             	mov    (%esp),%ebx
  800f1d:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f21:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f25:	89 ec                	mov    %ebp,%esp
  800f27:	5d                   	pop    %ebp
  800f28:	c3                   	ret    

00800f29 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800f29:	55                   	push   %ebp
  800f2a:	89 e5                	mov    %esp,%ebp
  800f2c:	83 ec 0c             	sub    $0xc,%esp
  800f2f:	89 1c 24             	mov    %ebx,(%esp)
  800f32:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f36:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f3a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f3f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800f44:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f47:	8b 55 08             	mov    0x8(%ebp),%edx
  800f4a:	89 df                	mov    %ebx,%edi
  800f4c:	89 de                	mov    %ebx,%esi
  800f4e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800f50:	8b 1c 24             	mov    (%esp),%ebx
  800f53:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f57:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f5b:	89 ec                	mov    %ebp,%esp
  800f5d:	5d                   	pop    %ebp
  800f5e:	c3                   	ret    

00800f5f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800f5f:	55                   	push   %ebp
  800f60:	89 e5                	mov    %esp,%ebp
  800f62:	83 ec 0c             	sub    $0xc,%esp
  800f65:	89 1c 24             	mov    %ebx,(%esp)
  800f68:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f6c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f70:	ba 00 00 00 00       	mov    $0x0,%edx
  800f75:	b8 0e 00 00 00       	mov    $0xe,%eax
  800f7a:	89 d1                	mov    %edx,%ecx
  800f7c:	89 d3                	mov    %edx,%ebx
  800f7e:	89 d7                	mov    %edx,%edi
  800f80:	89 d6                	mov    %edx,%esi
  800f82:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800f84:	8b 1c 24             	mov    (%esp),%ebx
  800f87:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f8b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f8f:	89 ec                	mov    %ebp,%esp
  800f91:	5d                   	pop    %ebp
  800f92:	c3                   	ret    

00800f93 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800f93:	55                   	push   %ebp
  800f94:	89 e5                	mov    %esp,%ebp
  800f96:	83 ec 38             	sub    $0x38,%esp
  800f99:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f9c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f9f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fa2:	b9 00 00 00 00       	mov    $0x0,%ecx
  800fa7:	b8 0d 00 00 00       	mov    $0xd,%eax
  800fac:	8b 55 08             	mov    0x8(%ebp),%edx
  800faf:	89 cb                	mov    %ecx,%ebx
  800fb1:	89 cf                	mov    %ecx,%edi
  800fb3:	89 ce                	mov    %ecx,%esi
  800fb5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fb7:	85 c0                	test   %eax,%eax
  800fb9:	7e 28                	jle    800fe3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fbb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fbf:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800fc6:	00 
  800fc7:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  800fce:	00 
  800fcf:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fd6:	00 
  800fd7:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  800fde:	e8 4d f3 ff ff       	call   800330 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800fe3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fe6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fe9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800fec:	89 ec                	mov    %ebp,%esp
  800fee:	5d                   	pop    %ebp
  800fef:	c3                   	ret    

00800ff0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800ff0:	55                   	push   %ebp
  800ff1:	89 e5                	mov    %esp,%ebp
  800ff3:	83 ec 38             	sub    $0x38,%esp
  800ff6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ff9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800ffc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fff:	be 00 00 00 00       	mov    $0x0,%esi
  801004:	b8 0c 00 00 00       	mov    $0xc,%eax
  801009:	8b 7d 14             	mov    0x14(%ebp),%edi
  80100c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80100f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801012:	8b 55 08             	mov    0x8(%ebp),%edx
  801015:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801017:	85 c0                	test   %eax,%eax
  801019:	7e 28                	jle    801043 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  80101b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80101f:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  801026:	00 
  801027:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  80102e:	00 
  80102f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801036:	00 
  801037:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  80103e:	e8 ed f2 ff ff       	call   800330 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801043:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801046:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801049:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80104c:	89 ec                	mov    %ebp,%esp
  80104e:	5d                   	pop    %ebp
  80104f:	c3                   	ret    

00801050 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801050:	55                   	push   %ebp
  801051:	89 e5                	mov    %esp,%ebp
  801053:	83 ec 38             	sub    $0x38,%esp
  801056:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801059:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80105c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80105f:	bb 00 00 00 00       	mov    $0x0,%ebx
  801064:	b8 0a 00 00 00       	mov    $0xa,%eax
  801069:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80106c:	8b 55 08             	mov    0x8(%ebp),%edx
  80106f:	89 df                	mov    %ebx,%edi
  801071:	89 de                	mov    %ebx,%esi
  801073:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801075:	85 c0                	test   %eax,%eax
  801077:	7e 28                	jle    8010a1 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801079:	89 44 24 10          	mov    %eax,0x10(%esp)
  80107d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  801084:	00 
  801085:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  80108c:	00 
  80108d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801094:	00 
  801095:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  80109c:	e8 8f f2 ff ff       	call   800330 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  8010a1:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010a4:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010a7:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010aa:	89 ec                	mov    %ebp,%esp
  8010ac:	5d                   	pop    %ebp
  8010ad:	c3                   	ret    

008010ae <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  8010ae:	55                   	push   %ebp
  8010af:	89 e5                	mov    %esp,%ebp
  8010b1:	83 ec 38             	sub    $0x38,%esp
  8010b4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010b7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010ba:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010bd:	bb 00 00 00 00       	mov    $0x0,%ebx
  8010c2:	b8 09 00 00 00       	mov    $0x9,%eax
  8010c7:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010ca:	8b 55 08             	mov    0x8(%ebp),%edx
  8010cd:	89 df                	mov    %ebx,%edi
  8010cf:	89 de                	mov    %ebx,%esi
  8010d1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010d3:	85 c0                	test   %eax,%eax
  8010d5:	7e 28                	jle    8010ff <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010d7:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010db:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  8010e2:	00 
  8010e3:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  8010ea:	00 
  8010eb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010f2:	00 
  8010f3:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  8010fa:	e8 31 f2 ff ff       	call   800330 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  8010ff:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801102:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801105:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801108:	89 ec                	mov    %ebp,%esp
  80110a:	5d                   	pop    %ebp
  80110b:	c3                   	ret    

0080110c <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  80110c:	55                   	push   %ebp
  80110d:	89 e5                	mov    %esp,%ebp
  80110f:	83 ec 38             	sub    $0x38,%esp
  801112:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801115:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801118:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80111b:	bb 00 00 00 00       	mov    $0x0,%ebx
  801120:	b8 08 00 00 00       	mov    $0x8,%eax
  801125:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801128:	8b 55 08             	mov    0x8(%ebp),%edx
  80112b:	89 df                	mov    %ebx,%edi
  80112d:	89 de                	mov    %ebx,%esi
  80112f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801131:	85 c0                	test   %eax,%eax
  801133:	7e 28                	jle    80115d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801135:	89 44 24 10          	mov    %eax,0x10(%esp)
  801139:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801140:	00 
  801141:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  801148:	00 
  801149:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801150:	00 
  801151:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  801158:	e8 d3 f1 ff ff       	call   800330 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80115d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801160:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801163:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801166:	89 ec                	mov    %ebp,%esp
  801168:	5d                   	pop    %ebp
  801169:	c3                   	ret    

0080116a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80116a:	55                   	push   %ebp
  80116b:	89 e5                	mov    %esp,%ebp
  80116d:	83 ec 38             	sub    $0x38,%esp
  801170:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801173:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801176:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801179:	bb 00 00 00 00       	mov    $0x0,%ebx
  80117e:	b8 06 00 00 00       	mov    $0x6,%eax
  801183:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801186:	8b 55 08             	mov    0x8(%ebp),%edx
  801189:	89 df                	mov    %ebx,%edi
  80118b:	89 de                	mov    %ebx,%esi
  80118d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80118f:	85 c0                	test   %eax,%eax
  801191:	7e 28                	jle    8011bb <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801193:	89 44 24 10          	mov    %eax,0x10(%esp)
  801197:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80119e:	00 
  80119f:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  8011a6:	00 
  8011a7:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011ae:	00 
  8011af:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  8011b6:	e8 75 f1 ff ff       	call   800330 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  8011bb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011be:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011c1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011c4:	89 ec                	mov    %ebp,%esp
  8011c6:	5d                   	pop    %ebp
  8011c7:	c3                   	ret    

008011c8 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  8011c8:	55                   	push   %ebp
  8011c9:	89 e5                	mov    %esp,%ebp
  8011cb:	83 ec 38             	sub    $0x38,%esp
  8011ce:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011d1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011d4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011d7:	b8 05 00 00 00       	mov    $0x5,%eax
  8011dc:	8b 75 18             	mov    0x18(%ebp),%esi
  8011df:	8b 7d 14             	mov    0x14(%ebp),%edi
  8011e2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8011e5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011e8:	8b 55 08             	mov    0x8(%ebp),%edx
  8011eb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011ed:	85 c0                	test   %eax,%eax
  8011ef:	7e 28                	jle    801219 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011f1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011f5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8011fc:	00 
  8011fd:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  801204:	00 
  801205:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80120c:	00 
  80120d:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  801214:	e8 17 f1 ff ff       	call   800330 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  801219:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80121c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80121f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801222:	89 ec                	mov    %ebp,%esp
  801224:	5d                   	pop    %ebp
  801225:	c3                   	ret    

00801226 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  801226:	55                   	push   %ebp
  801227:	89 e5                	mov    %esp,%ebp
  801229:	83 ec 38             	sub    $0x38,%esp
  80122c:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80122f:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801232:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801235:	be 00 00 00 00       	mov    $0x0,%esi
  80123a:	b8 04 00 00 00       	mov    $0x4,%eax
  80123f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801242:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801245:	8b 55 08             	mov    0x8(%ebp),%edx
  801248:	89 f7                	mov    %esi,%edi
  80124a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80124c:	85 c0                	test   %eax,%eax
  80124e:	7e 28                	jle    801278 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801250:	89 44 24 10          	mov    %eax,0x10(%esp)
  801254:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80125b:	00 
  80125c:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  801263:	00 
  801264:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80126b:	00 
  80126c:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  801273:	e8 b8 f0 ff ff       	call   800330 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801278:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80127b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80127e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801281:	89 ec                	mov    %ebp,%esp
  801283:	5d                   	pop    %ebp
  801284:	c3                   	ret    

00801285 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801285:	55                   	push   %ebp
  801286:	89 e5                	mov    %esp,%ebp
  801288:	83 ec 0c             	sub    $0xc,%esp
  80128b:	89 1c 24             	mov    %ebx,(%esp)
  80128e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801292:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801296:	ba 00 00 00 00       	mov    $0x0,%edx
  80129b:	b8 0b 00 00 00       	mov    $0xb,%eax
  8012a0:	89 d1                	mov    %edx,%ecx
  8012a2:	89 d3                	mov    %edx,%ebx
  8012a4:	89 d7                	mov    %edx,%edi
  8012a6:	89 d6                	mov    %edx,%esi
  8012a8:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  8012aa:	8b 1c 24             	mov    (%esp),%ebx
  8012ad:	8b 74 24 04          	mov    0x4(%esp),%esi
  8012b1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8012b5:	89 ec                	mov    %ebp,%esp
  8012b7:	5d                   	pop    %ebp
  8012b8:	c3                   	ret    

008012b9 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  8012b9:	55                   	push   %ebp
  8012ba:	89 e5                	mov    %esp,%ebp
  8012bc:	83 ec 0c             	sub    $0xc,%esp
  8012bf:	89 1c 24             	mov    %ebx,(%esp)
  8012c2:	89 74 24 04          	mov    %esi,0x4(%esp)
  8012c6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012ca:	ba 00 00 00 00       	mov    $0x0,%edx
  8012cf:	b8 02 00 00 00       	mov    $0x2,%eax
  8012d4:	89 d1                	mov    %edx,%ecx
  8012d6:	89 d3                	mov    %edx,%ebx
  8012d8:	89 d7                	mov    %edx,%edi
  8012da:	89 d6                	mov    %edx,%esi
  8012dc:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8012de:	8b 1c 24             	mov    (%esp),%ebx
  8012e1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8012e5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8012e9:	89 ec                	mov    %ebp,%esp
  8012eb:	5d                   	pop    %ebp
  8012ec:	c3                   	ret    

008012ed <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8012ed:	55                   	push   %ebp
  8012ee:	89 e5                	mov    %esp,%ebp
  8012f0:	83 ec 38             	sub    $0x38,%esp
  8012f3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012f6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8012f9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012fc:	b9 00 00 00 00       	mov    $0x0,%ecx
  801301:	b8 03 00 00 00       	mov    $0x3,%eax
  801306:	8b 55 08             	mov    0x8(%ebp),%edx
  801309:	89 cb                	mov    %ecx,%ebx
  80130b:	89 cf                	mov    %ecx,%edi
  80130d:	89 ce                	mov    %ecx,%esi
  80130f:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801311:	85 c0                	test   %eax,%eax
  801313:	7e 28                	jle    80133d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  801315:	89 44 24 10          	mov    %eax,0x10(%esp)
  801319:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  801320:	00 
  801321:	c7 44 24 08 eb 32 80 	movl   $0x8032eb,0x8(%esp)
  801328:	00 
  801329:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801330:	00 
  801331:	c7 04 24 08 33 80 00 	movl   $0x803308,(%esp)
  801338:	e8 f3 ef ff ff       	call   800330 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80133d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801340:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801343:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801346:	89 ec                	mov    %ebp,%esp
  801348:	5d                   	pop    %ebp
  801349:	c3                   	ret    
  80134a:	00 00                	add    %al,(%eax)
  80134c:	00 00                	add    %al,(%eax)
	...

00801350 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801350:	55                   	push   %ebp
  801351:	89 e5                	mov    %esp,%ebp
  801353:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801356:	c7 44 24 08 16 33 80 	movl   $0x803316,0x8(%esp)
  80135d:	00 
  80135e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801365:	00 
  801366:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  80136d:	e8 be ef ff ff       	call   800330 <_panic>

00801372 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801372:	55                   	push   %ebp
  801373:	89 e5                	mov    %esp,%ebp
  801375:	57                   	push   %edi
  801376:	56                   	push   %esi
  801377:	53                   	push   %ebx
  801378:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  80137b:	c7 04 24 dc 15 80 00 	movl   $0x8015dc,(%esp)
  801382:	e8 5d 17 00 00       	call   802ae4 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801387:	ba 07 00 00 00       	mov    $0x7,%edx
  80138c:	89 d0                	mov    %edx,%eax
  80138e:	cd 30                	int    $0x30
  801390:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  801393:	85 c0                	test   %eax,%eax
  801395:	79 20                	jns    8013b7 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  801397:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80139b:	c7 44 24 08 9c 33 80 	movl   $0x80339c,0x8(%esp)
  8013a2:	00 
  8013a3:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  8013aa:	00 
  8013ab:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  8013b2:	e8 79 ef ff ff       	call   800330 <_panic>
    } else if (childId>0) {
  8013b7:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8013bb:	0f 8e f3 01 00 00    	jle    8015b4 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  8013c1:	c7 44 24 04 54 2b 80 	movl   $0x802b54,0x4(%esp)
  8013c8:	00 
  8013c9:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8013cc:	89 04 24             	mov    %eax,(%esp)
  8013cf:	e8 7c fc ff ff       	call   801050 <sys_env_set_pgfault_upcall>
  8013d4:	85 c0                	test   %eax,%eax
  8013d6:	74 20                	je     8013f8 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  8013d8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8013dc:	c7 44 24 08 c0 33 80 	movl   $0x8033c0,0x8(%esp)
  8013e3:	00 
  8013e4:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  8013eb:	00 
  8013ec:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  8013f3:	e8 38 ef ff ff       	call   800330 <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  8013f8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8013ff:	00 
  801400:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  801407:	ee 
  801408:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80140b:	89 04 24             	mov    %eax,(%esp)
  80140e:	e8 13 fe ff ff       	call   801226 <sys_page_alloc>
  801413:	85 c0                	test   %eax,%eax
  801415:	79 20                	jns    801437 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  801417:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80141b:	c7 44 24 08 f0 33 80 	movl   $0x8033f0,0x8(%esp)
  801422:	00 
  801423:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  80142a:	00 
  80142b:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  801432:	e8 f9 ee ff ff       	call   800330 <_panic>
  801437:	be 00 00 80 00       	mov    $0x800000,%esi
  80143c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801441:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801446:	89 f0                	mov    %esi,%eax
  801448:	c1 e8 16             	shr    $0x16,%eax
  80144b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80144e:	a8 01                	test   $0x1,%al
  801450:	0f 84 13 01 00 00    	je     801569 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801456:	89 f0                	mov    %esi,%eax
  801458:	c1 e8 0c             	shr    $0xc,%eax
  80145b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801462:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801465:	25 07 0e 00 00       	and    $0xe07,%eax
  80146a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  80146d:	e8 47 fe ff ff       	call   8012b9 <sys_getenvid>
  801472:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  801475:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  801479:	0f 84 ea 00 00 00    	je     801569 <fork+0x1f7>
  80147f:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  801486:	0f 84 9d 00 00 00    	je     801529 <fork+0x1b7>
  80148c:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  801493:	0f 85 90 00 00 00    	jne    801529 <fork+0x1b7>
    perm    &= (~PTE_W);
  801499:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80149c:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  80149f:	80 cc 08             	or     $0x8,%ah
  8014a2:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8014a5:	89 75 e0             	mov    %esi,-0x20(%ebp)
  8014a8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8014ac:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8014b0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8014b3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8014b7:	89 74 24 04          	mov    %esi,0x4(%esp)
  8014bb:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8014be:	89 04 24             	mov    %eax,(%esp)
  8014c1:	e8 02 fd ff ff       	call   8011c8 <sys_page_map>
  8014c6:	85 c0                	test   %eax,%eax
  8014c8:	79 1b                	jns    8014e5 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  8014ca:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014ce:	89 74 24 08          	mov    %esi,0x8(%esp)
  8014d2:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8014d5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014d9:	c7 04 24 18 34 80 00 	movl   $0x803418,(%esp)
  8014e0:	e8 10 ef ff ff       	call   8003f5 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  8014e5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8014e8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8014ec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8014ef:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014f3:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8014f6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8014fa:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8014fd:	89 44 24 04          	mov    %eax,0x4(%esp)
  801501:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801504:	89 04 24             	mov    %eax,(%esp)
  801507:	e8 bc fc ff ff       	call   8011c8 <sys_page_map>
  80150c:	85 c0                	test   %eax,%eax
  80150e:	79 59                	jns    801569 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  801510:	89 44 24 08          	mov    %eax,0x8(%esp)
  801514:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801517:	89 44 24 04          	mov    %eax,0x4(%esp)
  80151b:	c7 04 24 58 34 80 00 	movl   $0x803458,(%esp)
  801522:	e8 ce ee ff ff       	call   8003f5 <cprintf>
  801527:	eb 40                	jmp    801569 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801529:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80152c:	89 44 24 10          	mov    %eax,0x10(%esp)
  801530:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801534:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801537:	89 44 24 08          	mov    %eax,0x8(%esp)
  80153b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80153f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801542:	89 04 24             	mov    %eax,(%esp)
  801545:	e8 7e fc ff ff       	call   8011c8 <sys_page_map>
  80154a:	85 c0                	test   %eax,%eax
  80154c:	79 1b                	jns    801569 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80154e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801552:	89 74 24 08          	mov    %esi,0x8(%esp)
  801556:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801559:	89 44 24 04          	mov    %eax,0x4(%esp)
  80155d:	c7 04 24 18 34 80 00 	movl   $0x803418,(%esp)
  801564:	e8 8c ee ff ff       	call   8003f5 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801569:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80156f:	89 de                	mov    %ebx,%esi
  801571:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801577:	0f 85 c9 fe ff ff    	jne    801446 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  80157d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801584:	00 
  801585:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801588:	89 04 24             	mov    %eax,(%esp)
  80158b:	e8 7c fb ff ff       	call   80110c <sys_env_set_status>
  801590:	85 c0                	test   %eax,%eax
  801592:	79 3d                	jns    8015d1 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  801594:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801598:	c7 44 24 08 8c 34 80 	movl   $0x80348c,0x8(%esp)
  80159f:	00 
  8015a0:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  8015a7:	00 
  8015a8:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  8015af:	e8 7c ed ff ff       	call   800330 <_panic>
    } else if (childId==0) {
  8015b4:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8015b8:	75 17                	jne    8015d1 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  8015ba:	e8 fa fc ff ff       	call   8012b9 <sys_getenvid>
  8015bf:	25 ff 03 00 00       	and    $0x3ff,%eax
  8015c4:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8015c7:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8015cc:	a3 74 70 80 00       	mov    %eax,0x807074
    }
    return childId;
}
  8015d1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8015d4:	83 c4 3c             	add    $0x3c,%esp
  8015d7:	5b                   	pop    %ebx
  8015d8:	5e                   	pop    %esi
  8015d9:	5f                   	pop    %edi
  8015da:	5d                   	pop    %ebp
  8015db:	c3                   	ret    

008015dc <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  8015dc:	55                   	push   %ebp
  8015dd:	89 e5                	mov    %esp,%ebp
  8015df:	57                   	push   %edi
  8015e0:	56                   	push   %esi
  8015e1:	53                   	push   %ebx
  8015e2:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  8015e5:	8b 45 08             	mov    0x8(%ebp),%eax
  8015e8:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  8015ea:	8b 50 04             	mov    0x4(%eax),%edx
  8015ed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  8015f0:	89 fe                	mov    %edi,%esi
  8015f2:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  8015f8:	e8 bc fc ff ff       	call   8012b9 <sys_getenvid>
  8015fd:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  8015ff:	89 f2                	mov    %esi,%edx
  801601:	89 f0                	mov    %esi,%eax
  801603:	c1 e8 16             	shr    $0x16,%eax
  801606:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  80160d:	a8 01                	test   $0x1,%al
  80160f:	74 3e                	je     80164f <pgfault+0x73>
  801611:	c1 ea 0c             	shr    $0xc,%edx
  801614:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  80161b:	a8 01                	test   $0x1,%al
  80161d:	74 30                	je     80164f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  80161f:	c1 ef 0c             	shr    $0xc,%edi
  801622:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  801629:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  80162f:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801632:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801636:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80163d:	00 
  80163e:	89 1c 24             	mov    %ebx,(%esp)
  801641:	e8 e0 fb ff ff       	call   801226 <sys_page_alloc>
  801646:	85 c0                	test   %eax,%eax
  801648:	74 46                	je     801690 <pgfault+0xb4>
  80164a:	e9 cd 00 00 00       	jmp    80171c <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80164f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801652:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801656:	8b 55 08             	mov    0x8(%ebp),%edx
  801659:	8b 42 28             	mov    0x28(%edx),%eax
  80165c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801660:	89 74 24 04          	mov    %esi,0x4(%esp)
  801664:	c7 04 24 ac 34 80 00 	movl   $0x8034ac,(%esp)
  80166b:	e8 85 ed ff ff       	call   8003f5 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  801670:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801674:	c7 44 24 08 37 33 80 	movl   $0x803337,0x8(%esp)
  80167b:	00 
  80167c:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801683:	00 
  801684:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  80168b:	e8 a0 ec ff ff       	call   800330 <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  801690:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801697:	00 
  801698:	89 74 24 04          	mov    %esi,0x4(%esp)
  80169c:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  8016a3:	e8 dd f5 ff ff       	call   800c85 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  8016a8:	89 7c 24 10          	mov    %edi,0x10(%esp)
  8016ac:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8016b0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8016b4:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8016bb:	00 
  8016bc:	89 1c 24             	mov    %ebx,(%esp)
  8016bf:	e8 04 fb ff ff       	call   8011c8 <sys_page_map>
  8016c4:	85 c0                	test   %eax,%eax
  8016c6:	74 20                	je     8016e8 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  8016c8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8016cc:	c7 44 24 08 49 33 80 	movl   $0x803349,0x8(%esp)
  8016d3:	00 
  8016d4:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  8016db:	00 
  8016dc:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  8016e3:	e8 48 ec ff ff       	call   800330 <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  8016e8:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8016ef:	00 
  8016f0:	89 1c 24             	mov    %ebx,(%esp)
  8016f3:	e8 72 fa ff ff       	call   80116a <sys_page_unmap>
  8016f8:	85 c0                	test   %eax,%eax
  8016fa:	74 40                	je     80173c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  8016fc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801700:	c7 44 24 08 64 33 80 	movl   $0x803364,0x8(%esp)
  801707:	00 
  801708:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  80170f:	00 
  801710:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  801717:	e8 14 ec ff ff       	call   800330 <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  80171c:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801720:	c7 44 24 08 81 33 80 	movl   $0x803381,0x8(%esp)
  801727:	00 
  801728:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  80172f:	00 
  801730:	c7 04 24 2c 33 80 00 	movl   $0x80332c,(%esp)
  801737:	e8 f4 eb ff ff       	call   800330 <_panic>
}
  80173c:	83 c4 3c             	add    $0x3c,%esp
  80173f:	5b                   	pop    %ebx
  801740:	5e                   	pop    %esi
  801741:	5f                   	pop    %edi
  801742:	5d                   	pop    %ebp
  801743:	c3                   	ret    
	...

00801750 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801750:	55                   	push   %ebp
  801751:	89 e5                	mov    %esp,%ebp
  801753:	8b 45 08             	mov    0x8(%ebp),%eax
  801756:	05 00 00 00 30       	add    $0x30000000,%eax
  80175b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80175e:	5d                   	pop    %ebp
  80175f:	c3                   	ret    

00801760 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801760:	55                   	push   %ebp
  801761:	89 e5                	mov    %esp,%ebp
  801763:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801766:	8b 45 08             	mov    0x8(%ebp),%eax
  801769:	89 04 24             	mov    %eax,(%esp)
  80176c:	e8 df ff ff ff       	call   801750 <fd2num>
  801771:	05 20 00 0d 00       	add    $0xd0020,%eax
  801776:	c1 e0 0c             	shl    $0xc,%eax
}
  801779:	c9                   	leave  
  80177a:	c3                   	ret    

0080177b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80177b:	55                   	push   %ebp
  80177c:	89 e5                	mov    %esp,%ebp
  80177e:	57                   	push   %edi
  80177f:	56                   	push   %esi
  801780:	53                   	push   %ebx
  801781:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801784:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801789:	a8 01                	test   $0x1,%al
  80178b:	74 36                	je     8017c3 <fd_alloc+0x48>
  80178d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801792:	a8 01                	test   $0x1,%al
  801794:	74 2d                	je     8017c3 <fd_alloc+0x48>
  801796:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80179b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  8017a0:	be 00 00 40 ef       	mov    $0xef400000,%esi
  8017a5:	89 c3                	mov    %eax,%ebx
  8017a7:	89 c2                	mov    %eax,%edx
  8017a9:	c1 ea 16             	shr    $0x16,%edx
  8017ac:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  8017af:	f6 c2 01             	test   $0x1,%dl
  8017b2:	74 14                	je     8017c8 <fd_alloc+0x4d>
  8017b4:	89 c2                	mov    %eax,%edx
  8017b6:	c1 ea 0c             	shr    $0xc,%edx
  8017b9:	8b 14 96             	mov    (%esi,%edx,4),%edx
  8017bc:	f6 c2 01             	test   $0x1,%dl
  8017bf:	75 10                	jne    8017d1 <fd_alloc+0x56>
  8017c1:	eb 05                	jmp    8017c8 <fd_alloc+0x4d>
  8017c3:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  8017c8:	89 1f                	mov    %ebx,(%edi)
  8017ca:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  8017cf:	eb 17                	jmp    8017e8 <fd_alloc+0x6d>
  8017d1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8017d6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8017db:	75 c8                	jne    8017a5 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8017dd:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8017e3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8017e8:	5b                   	pop    %ebx
  8017e9:	5e                   	pop    %esi
  8017ea:	5f                   	pop    %edi
  8017eb:	5d                   	pop    %ebp
  8017ec:	c3                   	ret    

008017ed <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8017ed:	55                   	push   %ebp
  8017ee:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8017f0:	8b 45 08             	mov    0x8(%ebp),%eax
  8017f3:	83 f8 1f             	cmp    $0x1f,%eax
  8017f6:	77 36                	ja     80182e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8017f8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8017fd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  801800:	89 c2                	mov    %eax,%edx
  801802:	c1 ea 16             	shr    $0x16,%edx
  801805:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  80180c:	f6 c2 01             	test   $0x1,%dl
  80180f:	74 1d                	je     80182e <fd_lookup+0x41>
  801811:	89 c2                	mov    %eax,%edx
  801813:	c1 ea 0c             	shr    $0xc,%edx
  801816:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  80181d:	f6 c2 01             	test   $0x1,%dl
  801820:	74 0c                	je     80182e <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  801822:	8b 55 0c             	mov    0xc(%ebp),%edx
  801825:	89 02                	mov    %eax,(%edx)
  801827:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  80182c:	eb 05                	jmp    801833 <fd_lookup+0x46>
  80182e:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801833:	5d                   	pop    %ebp
  801834:	c3                   	ret    

00801835 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801835:	55                   	push   %ebp
  801836:	89 e5                	mov    %esp,%ebp
  801838:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80183b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80183e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801842:	8b 45 08             	mov    0x8(%ebp),%eax
  801845:	89 04 24             	mov    %eax,(%esp)
  801848:	e8 a0 ff ff ff       	call   8017ed <fd_lookup>
  80184d:	85 c0                	test   %eax,%eax
  80184f:	78 0e                	js     80185f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801851:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801854:	8b 55 0c             	mov    0xc(%ebp),%edx
  801857:	89 50 04             	mov    %edx,0x4(%eax)
  80185a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80185f:	c9                   	leave  
  801860:	c3                   	ret    

00801861 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801861:	55                   	push   %ebp
  801862:	89 e5                	mov    %esp,%ebp
  801864:	56                   	push   %esi
  801865:	53                   	push   %ebx
  801866:	83 ec 10             	sub    $0x10,%esp
  801869:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80186c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80186f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801874:	b8 04 70 80 00       	mov    $0x807004,%eax
  801879:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  80187f:	75 11                	jne    801892 <dev_lookup+0x31>
  801881:	eb 04                	jmp    801887 <dev_lookup+0x26>
  801883:	39 08                	cmp    %ecx,(%eax)
  801885:	75 10                	jne    801897 <dev_lookup+0x36>
			*dev = devtab[i];
  801887:	89 03                	mov    %eax,(%ebx)
  801889:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80188e:	66 90                	xchg   %ax,%ax
  801890:	eb 36                	jmp    8018c8 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801892:	be 54 35 80 00       	mov    $0x803554,%esi
  801897:	83 c2 01             	add    $0x1,%edx
  80189a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80189d:	85 c0                	test   %eax,%eax
  80189f:	75 e2                	jne    801883 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  8018a1:	a1 74 70 80 00       	mov    0x807074,%eax
  8018a6:	8b 40 4c             	mov    0x4c(%eax),%eax
  8018a9:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8018ad:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018b1:	c7 04 24 d8 34 80 00 	movl   $0x8034d8,(%esp)
  8018b8:	e8 38 eb ff ff       	call   8003f5 <cprintf>
	*dev = 0;
  8018bd:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  8018c3:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  8018c8:	83 c4 10             	add    $0x10,%esp
  8018cb:	5b                   	pop    %ebx
  8018cc:	5e                   	pop    %esi
  8018cd:	5d                   	pop    %ebp
  8018ce:	c3                   	ret    

008018cf <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  8018cf:	55                   	push   %ebp
  8018d0:	89 e5                	mov    %esp,%ebp
  8018d2:	53                   	push   %ebx
  8018d3:	83 ec 24             	sub    $0x24,%esp
  8018d6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8018d9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8018dc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018e0:	8b 45 08             	mov    0x8(%ebp),%eax
  8018e3:	89 04 24             	mov    %eax,(%esp)
  8018e6:	e8 02 ff ff ff       	call   8017ed <fd_lookup>
  8018eb:	85 c0                	test   %eax,%eax
  8018ed:	78 53                	js     801942 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8018ef:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8018f2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018f6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8018f9:	8b 00                	mov    (%eax),%eax
  8018fb:	89 04 24             	mov    %eax,(%esp)
  8018fe:	e8 5e ff ff ff       	call   801861 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801903:	85 c0                	test   %eax,%eax
  801905:	78 3b                	js     801942 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  801907:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80190c:	8b 55 f4             	mov    -0xc(%ebp),%edx
  80190f:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  801913:	74 2d                	je     801942 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  801915:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  801918:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  80191f:	00 00 00 
	stat->st_isdir = 0;
  801922:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  801929:	00 00 00 
	stat->st_dev = dev;
  80192c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80192f:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801935:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801939:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80193c:	89 14 24             	mov    %edx,(%esp)
  80193f:	ff 50 14             	call   *0x14(%eax)
}
  801942:	83 c4 24             	add    $0x24,%esp
  801945:	5b                   	pop    %ebx
  801946:	5d                   	pop    %ebp
  801947:	c3                   	ret    

00801948 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801948:	55                   	push   %ebp
  801949:	89 e5                	mov    %esp,%ebp
  80194b:	53                   	push   %ebx
  80194c:	83 ec 24             	sub    $0x24,%esp
  80194f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801952:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801955:	89 44 24 04          	mov    %eax,0x4(%esp)
  801959:	89 1c 24             	mov    %ebx,(%esp)
  80195c:	e8 8c fe ff ff       	call   8017ed <fd_lookup>
  801961:	85 c0                	test   %eax,%eax
  801963:	78 5f                	js     8019c4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801965:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801968:	89 44 24 04          	mov    %eax,0x4(%esp)
  80196c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80196f:	8b 00                	mov    (%eax),%eax
  801971:	89 04 24             	mov    %eax,(%esp)
  801974:	e8 e8 fe ff ff       	call   801861 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801979:	85 c0                	test   %eax,%eax
  80197b:	78 47                	js     8019c4 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80197d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801980:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801984:	75 23                	jne    8019a9 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801986:	a1 74 70 80 00       	mov    0x807074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80198b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80198e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801992:	89 44 24 04          	mov    %eax,0x4(%esp)
  801996:	c7 04 24 f8 34 80 00 	movl   $0x8034f8,(%esp)
  80199d:	e8 53 ea ff ff       	call   8003f5 <cprintf>
  8019a2:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  8019a7:	eb 1b                	jmp    8019c4 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  8019a9:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8019ac:	8b 48 18             	mov    0x18(%eax),%ecx
  8019af:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8019b4:	85 c9                	test   %ecx,%ecx
  8019b6:	74 0c                	je     8019c4 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  8019b8:	8b 45 0c             	mov    0xc(%ebp),%eax
  8019bb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019bf:	89 14 24             	mov    %edx,(%esp)
  8019c2:	ff d1                	call   *%ecx
}
  8019c4:	83 c4 24             	add    $0x24,%esp
  8019c7:	5b                   	pop    %ebx
  8019c8:	5d                   	pop    %ebp
  8019c9:	c3                   	ret    

008019ca <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  8019ca:	55                   	push   %ebp
  8019cb:	89 e5                	mov    %esp,%ebp
  8019cd:	53                   	push   %ebx
  8019ce:	83 ec 24             	sub    $0x24,%esp
  8019d1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8019d4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8019d7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019db:	89 1c 24             	mov    %ebx,(%esp)
  8019de:	e8 0a fe ff ff       	call   8017ed <fd_lookup>
  8019e3:	85 c0                	test   %eax,%eax
  8019e5:	78 66                	js     801a4d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8019e7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8019ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019ee:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8019f1:	8b 00                	mov    (%eax),%eax
  8019f3:	89 04 24             	mov    %eax,(%esp)
  8019f6:	e8 66 fe ff ff       	call   801861 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8019fb:	85 c0                	test   %eax,%eax
  8019fd:	78 4e                	js     801a4d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8019ff:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801a02:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801a06:	75 23                	jne    801a2b <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  801a08:	a1 74 70 80 00       	mov    0x807074,%eax
  801a0d:	8b 40 4c             	mov    0x4c(%eax),%eax
  801a10:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801a14:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a18:	c7 04 24 19 35 80 00 	movl   $0x803519,(%esp)
  801a1f:	e8 d1 e9 ff ff       	call   8003f5 <cprintf>
  801a24:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801a29:	eb 22                	jmp    801a4d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  801a2b:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a2e:	8b 48 0c             	mov    0xc(%eax),%ecx
  801a31:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801a36:	85 c9                	test   %ecx,%ecx
  801a38:	74 13                	je     801a4d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  801a3a:	8b 45 10             	mov    0x10(%ebp),%eax
  801a3d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a41:	8b 45 0c             	mov    0xc(%ebp),%eax
  801a44:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a48:	89 14 24             	mov    %edx,(%esp)
  801a4b:	ff d1                	call   *%ecx
}
  801a4d:	83 c4 24             	add    $0x24,%esp
  801a50:	5b                   	pop    %ebx
  801a51:	5d                   	pop    %ebp
  801a52:	c3                   	ret    

00801a53 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801a53:	55                   	push   %ebp
  801a54:	89 e5                	mov    %esp,%ebp
  801a56:	57                   	push   %edi
  801a57:	56                   	push   %esi
  801a58:	53                   	push   %ebx
  801a59:	83 ec 2c             	sub    $0x2c,%esp
  801a5c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  801a5f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a62:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801a65:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a69:	89 1c 24             	mov    %ebx,(%esp)
  801a6c:	e8 7c fd ff ff       	call   8017ed <fd_lookup>
  801a71:	85 c0                	test   %eax,%eax
  801a73:	0f 88 b0 00 00 00    	js     801b29 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801a79:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801a7c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a80:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801a83:	8b 00                	mov    (%eax),%eax
  801a85:	89 04 24             	mov    %eax,(%esp)
  801a88:	e8 d4 fd ff ff       	call   801861 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801a8d:	85 c0                	test   %eax,%eax
  801a8f:	0f 88 94 00 00 00    	js     801b29 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801a95:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801a98:	8b 40 08             	mov    0x8(%eax),%eax
  801a9b:	83 e0 03             	and    $0x3,%eax
  801a9e:	83 f8 01             	cmp    $0x1,%eax
  801aa1:	75 23                	jne    801ac6 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801aa3:	a1 74 70 80 00       	mov    0x807074,%eax
  801aa8:	8b 40 4c             	mov    0x4c(%eax),%eax
  801aab:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801aaf:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ab3:	c7 04 24 36 35 80 00 	movl   $0x803536,(%esp)
  801aba:	e8 36 e9 ff ff       	call   8003f5 <cprintf>
  801abf:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801ac4:	eb 63                	jmp    801b29 <read+0xd6>
	}
	if (!dev->dev_read)
  801ac6:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801acb:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  801ace:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801ad2:	74 55                	je     801b29 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801ad4:	ba 00 00 00 00       	mov    $0x0,%edx
  801ad9:	bb 00 00 00 00       	mov    $0x0,%ebx
  801ade:	b8 00 00 00 00       	mov    $0x0,%eax
  801ae3:	85 f6                	test   %esi,%esi
  801ae5:	74 42                	je     801b29 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801ae7:	bf 00 10 00 00       	mov    $0x1000,%edi
  801aec:	89 f0                	mov    %esi,%eax
  801aee:	29 d0                	sub    %edx,%eax
  801af0:	89 c1                	mov    %eax,%ecx
  801af2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  801af8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  801afd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  801b00:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  801b04:	03 55 0c             	add    0xc(%ebp),%edx
  801b07:	89 54 24 04          	mov    %edx,0x4(%esp)
  801b0b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801b0e:	89 04 24             	mov    %eax,(%esp)
  801b11:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801b14:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  801b17:	85 c0                	test   %eax,%eax
  801b19:	78 0e                	js     801b29 <read+0xd6>
			return m;
		if (m == 0)
  801b1b:	85 c0                	test   %eax,%eax
  801b1d:	74 08                	je     801b27 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801b1f:	01 c3                	add    %eax,%ebx
  801b21:	89 da                	mov    %ebx,%edx
  801b23:	39 f3                	cmp    %esi,%ebx
  801b25:	72 c5                	jb     801aec <read+0x99>
  801b27:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801b29:	83 c4 2c             	add    $0x2c,%esp
  801b2c:	5b                   	pop    %ebx
  801b2d:	5e                   	pop    %esi
  801b2e:	5f                   	pop    %edi
  801b2f:	5d                   	pop    %ebp
  801b30:	c3                   	ret    

00801b31 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801b31:	55                   	push   %ebp
  801b32:	89 e5                	mov    %esp,%ebp
  801b34:	57                   	push   %edi
  801b35:	56                   	push   %esi
  801b36:	53                   	push   %ebx
  801b37:	83 ec 1c             	sub    $0x1c,%esp
  801b3a:	8b 7d 08             	mov    0x8(%ebp),%edi
  801b3d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801b40:	ba 00 00 00 00       	mov    $0x0,%edx
  801b45:	bb 00 00 00 00       	mov    $0x0,%ebx
  801b4a:	b8 00 00 00 00       	mov    $0x0,%eax
  801b4f:	85 f6                	test   %esi,%esi
  801b51:	74 29                	je     801b7c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801b53:	89 f0                	mov    %esi,%eax
  801b55:	29 d0                	sub    %edx,%eax
  801b57:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b5b:	03 55 0c             	add    0xc(%ebp),%edx
  801b5e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801b62:	89 3c 24             	mov    %edi,(%esp)
  801b65:	e8 e9 fe ff ff       	call   801a53 <read>
		if (m < 0)
  801b6a:	85 c0                	test   %eax,%eax
  801b6c:	78 0e                	js     801b7c <readn+0x4b>
			return m;
		if (m == 0)
  801b6e:	85 c0                	test   %eax,%eax
  801b70:	74 08                	je     801b7a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801b72:	01 c3                	add    %eax,%ebx
  801b74:	89 da                	mov    %ebx,%edx
  801b76:	39 f3                	cmp    %esi,%ebx
  801b78:	72 d9                	jb     801b53 <readn+0x22>
  801b7a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  801b7c:	83 c4 1c             	add    $0x1c,%esp
  801b7f:	5b                   	pop    %ebx
  801b80:	5e                   	pop    %esi
  801b81:	5f                   	pop    %edi
  801b82:	5d                   	pop    %ebp
  801b83:	c3                   	ret    

00801b84 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801b84:	55                   	push   %ebp
  801b85:	89 e5                	mov    %esp,%ebp
  801b87:	83 ec 28             	sub    $0x28,%esp
  801b8a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801b8d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801b90:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801b93:	89 34 24             	mov    %esi,(%esp)
  801b96:	e8 b5 fb ff ff       	call   801750 <fd2num>
  801b9b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801b9e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801ba2:	89 04 24             	mov    %eax,(%esp)
  801ba5:	e8 43 fc ff ff       	call   8017ed <fd_lookup>
  801baa:	89 c3                	mov    %eax,%ebx
  801bac:	85 c0                	test   %eax,%eax
  801bae:	78 05                	js     801bb5 <fd_close+0x31>
  801bb0:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801bb3:	74 0e                	je     801bc3 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801bb5:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801bb9:	b8 00 00 00 00       	mov    $0x0,%eax
  801bbe:	0f 44 d8             	cmove  %eax,%ebx
  801bc1:	eb 3d                	jmp    801c00 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801bc3:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801bc6:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bca:	8b 06                	mov    (%esi),%eax
  801bcc:	89 04 24             	mov    %eax,(%esp)
  801bcf:	e8 8d fc ff ff       	call   801861 <dev_lookup>
  801bd4:	89 c3                	mov    %eax,%ebx
  801bd6:	85 c0                	test   %eax,%eax
  801bd8:	78 16                	js     801bf0 <fd_close+0x6c>
		if (dev->dev_close)
  801bda:	8b 45 f0             	mov    -0x10(%ebp),%eax
  801bdd:	8b 40 10             	mov    0x10(%eax),%eax
  801be0:	bb 00 00 00 00       	mov    $0x0,%ebx
  801be5:	85 c0                	test   %eax,%eax
  801be7:	74 07                	je     801bf0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801be9:	89 34 24             	mov    %esi,(%esp)
  801bec:	ff d0                	call   *%eax
  801bee:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  801bf0:	89 74 24 04          	mov    %esi,0x4(%esp)
  801bf4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801bfb:	e8 6a f5 ff ff       	call   80116a <sys_page_unmap>
	return r;
}
  801c00:	89 d8                	mov    %ebx,%eax
  801c02:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801c05:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801c08:	89 ec                	mov    %ebp,%esp
  801c0a:	5d                   	pop    %ebp
  801c0b:	c3                   	ret    

00801c0c <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  801c0c:	55                   	push   %ebp
  801c0d:	89 e5                	mov    %esp,%ebp
  801c0f:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  801c12:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801c15:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c19:	8b 45 08             	mov    0x8(%ebp),%eax
  801c1c:	89 04 24             	mov    %eax,(%esp)
  801c1f:	e8 c9 fb ff ff       	call   8017ed <fd_lookup>
  801c24:	85 c0                	test   %eax,%eax
  801c26:	78 13                	js     801c3b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  801c28:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801c2f:	00 
  801c30:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801c33:	89 04 24             	mov    %eax,(%esp)
  801c36:	e8 49 ff ff ff       	call   801b84 <fd_close>
}
  801c3b:	c9                   	leave  
  801c3c:	c3                   	ret    

00801c3d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801c3d:	55                   	push   %ebp
  801c3e:	89 e5                	mov    %esp,%ebp
  801c40:	83 ec 18             	sub    $0x18,%esp
  801c43:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801c46:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801c49:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801c50:	00 
  801c51:	8b 45 08             	mov    0x8(%ebp),%eax
  801c54:	89 04 24             	mov    %eax,(%esp)
  801c57:	e8 80 03 00 00       	call   801fdc <open>
  801c5c:	89 c3                	mov    %eax,%ebx
  801c5e:	85 c0                	test   %eax,%eax
  801c60:	78 1b                	js     801c7d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801c62:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c65:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c69:	89 1c 24             	mov    %ebx,(%esp)
  801c6c:	e8 5e fc ff ff       	call   8018cf <fstat>
  801c71:	89 c6                	mov    %eax,%esi
	close(fd);
  801c73:	89 1c 24             	mov    %ebx,(%esp)
  801c76:	e8 91 ff ff ff       	call   801c0c <close>
  801c7b:	89 f3                	mov    %esi,%ebx
	return r;
}
  801c7d:	89 d8                	mov    %ebx,%eax
  801c7f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801c82:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801c85:	89 ec                	mov    %ebp,%esp
  801c87:	5d                   	pop    %ebp
  801c88:	c3                   	ret    

00801c89 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801c89:	55                   	push   %ebp
  801c8a:	89 e5                	mov    %esp,%ebp
  801c8c:	53                   	push   %ebx
  801c8d:	83 ec 14             	sub    $0x14,%esp
  801c90:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801c95:	89 1c 24             	mov    %ebx,(%esp)
  801c98:	e8 6f ff ff ff       	call   801c0c <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801c9d:	83 c3 01             	add    $0x1,%ebx
  801ca0:	83 fb 20             	cmp    $0x20,%ebx
  801ca3:	75 f0                	jne    801c95 <close_all+0xc>
		close(i);
}
  801ca5:	83 c4 14             	add    $0x14,%esp
  801ca8:	5b                   	pop    %ebx
  801ca9:	5d                   	pop    %ebp
  801caa:	c3                   	ret    

00801cab <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801cab:	55                   	push   %ebp
  801cac:	89 e5                	mov    %esp,%ebp
  801cae:	83 ec 58             	sub    $0x58,%esp
  801cb1:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801cb4:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801cb7:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801cba:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801cbd:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801cc0:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cc4:	8b 45 08             	mov    0x8(%ebp),%eax
  801cc7:	89 04 24             	mov    %eax,(%esp)
  801cca:	e8 1e fb ff ff       	call   8017ed <fd_lookup>
  801ccf:	89 c3                	mov    %eax,%ebx
  801cd1:	85 c0                	test   %eax,%eax
  801cd3:	0f 88 e0 00 00 00    	js     801db9 <dup+0x10e>
		return r;
	close(newfdnum);
  801cd9:	89 3c 24             	mov    %edi,(%esp)
  801cdc:	e8 2b ff ff ff       	call   801c0c <close>

	newfd = INDEX2FD(newfdnum);
  801ce1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801ce7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801cea:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801ced:	89 04 24             	mov    %eax,(%esp)
  801cf0:	e8 6b fa ff ff       	call   801760 <fd2data>
  801cf5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801cf7:	89 34 24             	mov    %esi,(%esp)
  801cfa:	e8 61 fa ff ff       	call   801760 <fd2data>
  801cff:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801d02:	89 da                	mov    %ebx,%edx
  801d04:	89 d8                	mov    %ebx,%eax
  801d06:	c1 e8 16             	shr    $0x16,%eax
  801d09:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801d10:	a8 01                	test   $0x1,%al
  801d12:	74 43                	je     801d57 <dup+0xac>
  801d14:	c1 ea 0c             	shr    $0xc,%edx
  801d17:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801d1e:	a8 01                	test   $0x1,%al
  801d20:	74 35                	je     801d57 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801d22:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801d29:	25 07 0e 00 00       	and    $0xe07,%eax
  801d2e:	89 44 24 10          	mov    %eax,0x10(%esp)
  801d32:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801d35:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801d39:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801d40:	00 
  801d41:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801d45:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d4c:	e8 77 f4 ff ff       	call   8011c8 <sys_page_map>
  801d51:	89 c3                	mov    %eax,%ebx
  801d53:	85 c0                	test   %eax,%eax
  801d55:	78 3f                	js     801d96 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801d57:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801d5a:	89 c2                	mov    %eax,%edx
  801d5c:	c1 ea 0c             	shr    $0xc,%edx
  801d5f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801d66:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801d6c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801d70:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801d74:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801d7b:	00 
  801d7c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d80:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d87:	e8 3c f4 ff ff       	call   8011c8 <sys_page_map>
  801d8c:	89 c3                	mov    %eax,%ebx
  801d8e:	85 c0                	test   %eax,%eax
  801d90:	78 04                	js     801d96 <dup+0xeb>
  801d92:	89 fb                	mov    %edi,%ebx
  801d94:	eb 23                	jmp    801db9 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801d96:	89 74 24 04          	mov    %esi,0x4(%esp)
  801d9a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801da1:	e8 c4 f3 ff ff       	call   80116a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801da6:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801da9:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dad:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801db4:	e8 b1 f3 ff ff       	call   80116a <sys_page_unmap>
	return r;
}
  801db9:	89 d8                	mov    %ebx,%eax
  801dbb:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801dbe:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801dc1:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801dc4:	89 ec                	mov    %ebp,%esp
  801dc6:	5d                   	pop    %ebp
  801dc7:	c3                   	ret    

00801dc8 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801dc8:	55                   	push   %ebp
  801dc9:	89 e5                	mov    %esp,%ebp
  801dcb:	53                   	push   %ebx
  801dcc:	83 ec 14             	sub    $0x14,%esp
  801dcf:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801dd1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801dd7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801dde:	00 
  801ddf:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801de6:	00 
  801de7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801deb:	89 14 24             	mov    %edx,(%esp)
  801dee:	e8 8d 0d 00 00       	call   802b80 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801df3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801dfa:	00 
  801dfb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801dff:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801e06:	e8 e7 0d 00 00       	call   802bf2 <ipc_recv>
}
  801e0b:	83 c4 14             	add    $0x14,%esp
  801e0e:	5b                   	pop    %ebx
  801e0f:	5d                   	pop    %ebp
  801e10:	c3                   	ret    

00801e11 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801e11:	55                   	push   %ebp
  801e12:	89 e5                	mov    %esp,%ebp
  801e14:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801e17:	8b 45 08             	mov    0x8(%ebp),%eax
  801e1a:	8b 40 0c             	mov    0xc(%eax),%eax
  801e1d:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801e22:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e25:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801e2a:	ba 00 00 00 00       	mov    $0x0,%edx
  801e2f:	b8 02 00 00 00       	mov    $0x2,%eax
  801e34:	e8 8f ff ff ff       	call   801dc8 <fsipc>
}
  801e39:	c9                   	leave  
  801e3a:	c3                   	ret    

00801e3b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801e3b:	55                   	push   %ebp
  801e3c:	89 e5                	mov    %esp,%ebp
  801e3e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801e41:	8b 45 08             	mov    0x8(%ebp),%eax
  801e44:	8b 40 0c             	mov    0xc(%eax),%eax
  801e47:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801e4c:	ba 00 00 00 00       	mov    $0x0,%edx
  801e51:	b8 06 00 00 00       	mov    $0x6,%eax
  801e56:	e8 6d ff ff ff       	call   801dc8 <fsipc>
}
  801e5b:	c9                   	leave  
  801e5c:	c3                   	ret    

00801e5d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801e5d:	55                   	push   %ebp
  801e5e:	89 e5                	mov    %esp,%ebp
  801e60:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801e63:	ba 00 00 00 00       	mov    $0x0,%edx
  801e68:	b8 08 00 00 00       	mov    $0x8,%eax
  801e6d:	e8 56 ff ff ff       	call   801dc8 <fsipc>
}
  801e72:	c9                   	leave  
  801e73:	c3                   	ret    

00801e74 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801e74:	55                   	push   %ebp
  801e75:	89 e5                	mov    %esp,%ebp
  801e77:	53                   	push   %ebx
  801e78:	83 ec 14             	sub    $0x14,%esp
  801e7b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801e7e:	8b 45 08             	mov    0x8(%ebp),%eax
  801e81:	8b 40 0c             	mov    0xc(%eax),%eax
  801e84:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801e89:	ba 00 00 00 00       	mov    $0x0,%edx
  801e8e:	b8 05 00 00 00       	mov    $0x5,%eax
  801e93:	e8 30 ff ff ff       	call   801dc8 <fsipc>
  801e98:	85 c0                	test   %eax,%eax
  801e9a:	78 2b                	js     801ec7 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801e9c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801ea3:	00 
  801ea4:	89 1c 24             	mov    %ebx,(%esp)
  801ea7:	e8 1e ec ff ff       	call   800aca <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801eac:	a1 80 40 80 00       	mov    0x804080,%eax
  801eb1:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801eb7:	a1 84 40 80 00       	mov    0x804084,%eax
  801ebc:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801ec2:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801ec7:	83 c4 14             	add    $0x14,%esp
  801eca:	5b                   	pop    %ebx
  801ecb:	5d                   	pop    %ebp
  801ecc:	c3                   	ret    

00801ecd <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801ecd:	55                   	push   %ebp
  801ece:	89 e5                	mov    %esp,%ebp
  801ed0:	53                   	push   %ebx
  801ed1:	83 ec 14             	sub    $0x14,%esp
  801ed4:	8b 45 08             	mov    0x8(%ebp),%eax
  801ed7:	8b 55 0c             	mov    0xc(%ebp),%edx
  801eda:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801edd:	85 c0                	test   %eax,%eax
  801edf:	74 44                	je     801f25 <devfile_write+0x58>
  801ee1:	85 d2                	test   %edx,%edx
  801ee3:	74 40                	je     801f25 <devfile_write+0x58>
  801ee5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801eeb:	77 38                	ja     801f25 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801eed:	8b 40 0c             	mov    0xc(%eax),%eax
  801ef0:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801ef5:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801efb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801eff:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f03:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801f0a:	e8 76 ed ff ff       	call   800c85 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801f0f:	ba 00 00 00 00       	mov    $0x0,%edx
  801f14:	b8 04 00 00 00       	mov    $0x4,%eax
  801f19:	e8 aa fe ff ff       	call   801dc8 <fsipc>
        return r;
    return n;
  801f1e:	85 c0                	test   %eax,%eax
  801f20:	0f 49 c3             	cmovns %ebx,%eax
  801f23:	eb 05                	jmp    801f2a <devfile_write+0x5d>
  801f25:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801f2a:	83 c4 14             	add    $0x14,%esp
  801f2d:	5b                   	pop    %ebx
  801f2e:	5d                   	pop    %ebp
  801f2f:	c3                   	ret    

00801f30 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801f30:	55                   	push   %ebp
  801f31:	89 e5                	mov    %esp,%ebp
  801f33:	83 ec 18             	sub    $0x18,%esp
  801f36:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801f39:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801f3c:	8b 45 08             	mov    0x8(%ebp),%eax
  801f3f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801f42:	85 c0                	test   %eax,%eax
  801f44:	74 04                	je     801f4a <devfile_read+0x1a>
  801f46:	85 f6                	test   %esi,%esi
  801f48:	75 07                	jne    801f51 <devfile_read+0x21>
  801f4a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801f4f:	eb 39                	jmp    801f8a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801f51:	8b 40 0c             	mov    0xc(%eax),%eax
  801f54:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801f59:	8b 45 10             	mov    0x10(%ebp),%eax
  801f5c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801f61:	ba 00 00 00 00       	mov    $0x0,%edx
  801f66:	b8 03 00 00 00       	mov    $0x3,%eax
  801f6b:	e8 58 fe ff ff       	call   801dc8 <fsipc>
  801f70:	89 c3                	mov    %eax,%ebx
  801f72:	85 c0                	test   %eax,%eax
  801f74:	78 14                	js     801f8a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801f76:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f7a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801f81:	00 
  801f82:	89 34 24             	mov    %esi,(%esp)
  801f85:	e8 fb ec ff ff       	call   800c85 <memmove>
  return r;
}
  801f8a:	89 d8                	mov    %ebx,%eax
  801f8c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801f8f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801f92:	89 ec                	mov    %ebp,%esp
  801f94:	5d                   	pop    %ebp
  801f95:	c3                   	ret    

00801f96 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801f96:	55                   	push   %ebp
  801f97:	89 e5                	mov    %esp,%ebp
  801f99:	53                   	push   %ebx
  801f9a:	83 ec 14             	sub    $0x14,%esp
  801f9d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801fa0:	89 1c 24             	mov    %ebx,(%esp)
  801fa3:	e8 d8 ea ff ff       	call   800a80 <strlen>
  801fa8:	89 c2                	mov    %eax,%edx
  801faa:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801faf:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801fb5:	7f 1f                	jg     801fd6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801fb7:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801fbb:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801fc2:	e8 03 eb ff ff       	call   800aca <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801fc7:	ba 00 00 00 00       	mov    $0x0,%edx
  801fcc:	b8 07 00 00 00       	mov    $0x7,%eax
  801fd1:	e8 f2 fd ff ff       	call   801dc8 <fsipc>
}
  801fd6:	83 c4 14             	add    $0x14,%esp
  801fd9:	5b                   	pop    %ebx
  801fda:	5d                   	pop    %ebp
  801fdb:	c3                   	ret    

00801fdc <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801fdc:	55                   	push   %ebp
  801fdd:	89 e5                	mov    %esp,%ebp
  801fdf:	83 ec 28             	sub    $0x28,%esp
  801fe2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801fe5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801fe8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801feb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801ff0:	85 f6                	test   %esi,%esi
  801ff2:	74 65                	je     802059 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801ff4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801ffb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ffe:	89 04 24             	mov    %eax,(%esp)
  802001:	e8 75 f7 ff ff       	call   80177b <fd_alloc>
  802006:	89 c3                	mov    %eax,%ebx
  802008:	85 c0                	test   %eax,%eax
  80200a:	78 4d                	js     802059 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  80200c:	89 74 24 04          	mov    %esi,0x4(%esp)
  802010:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  802017:	e8 ae ea ff ff       	call   800aca <strcpy>
	fsipcbuf.open.req_omode = mode;
  80201c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80201f:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  802024:	8b 55 f4             	mov    -0xc(%ebp),%edx
  802027:	b8 01 00 00 00       	mov    $0x1,%eax
  80202c:	e8 97 fd ff ff       	call   801dc8 <fsipc>
  802031:	89 c3                	mov    %eax,%ebx
  802033:	85 c0                	test   %eax,%eax
  802035:	79 15                	jns    80204c <open+0x70>
    fd_close(f, 0);
  802037:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80203e:	00 
  80203f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802042:	89 04 24             	mov    %eax,(%esp)
  802045:	e8 3a fb ff ff       	call   801b84 <fd_close>
    return r;
  80204a:	eb 0d                	jmp    802059 <open+0x7d>
  }
  return fd2num(f);
  80204c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80204f:	89 04 24             	mov    %eax,(%esp)
  802052:	e8 f9 f6 ff ff       	call   801750 <fd2num>
  802057:	89 c3                	mov    %eax,%ebx
}
  802059:	89 d8                	mov    %ebx,%eax
  80205b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80205e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802061:	89 ec                	mov    %ebp,%esp
  802063:	5d                   	pop    %ebp
  802064:	c3                   	ret    
	...

00802070 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  802070:	55                   	push   %ebp
  802071:	89 e5                	mov    %esp,%ebp
  802073:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  802076:	c7 44 24 04 68 35 80 	movl   $0x803568,0x4(%esp)
  80207d:	00 
  80207e:	8b 45 0c             	mov    0xc(%ebp),%eax
  802081:	89 04 24             	mov    %eax,(%esp)
  802084:	e8 41 ea ff ff       	call   800aca <strcpy>
	return 0;
}
  802089:	b8 00 00 00 00       	mov    $0x0,%eax
  80208e:	c9                   	leave  
  80208f:	c3                   	ret    

00802090 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  802090:	55                   	push   %ebp
  802091:	89 e5                	mov    %esp,%ebp
  802093:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  802096:	8b 45 08             	mov    0x8(%ebp),%eax
  802099:	8b 40 0c             	mov    0xc(%eax),%eax
  80209c:	89 04 24             	mov    %eax,(%esp)
  80209f:	e8 9d 02 00 00       	call   802341 <nsipc_close>
}
  8020a4:	c9                   	leave  
  8020a5:	c3                   	ret    

008020a6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  8020a6:	55                   	push   %ebp
  8020a7:	89 e5                	mov    %esp,%ebp
  8020a9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  8020ac:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8020b3:	00 
  8020b4:	8b 45 10             	mov    0x10(%ebp),%eax
  8020b7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8020bb:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020be:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020c2:	8b 45 08             	mov    0x8(%ebp),%eax
  8020c5:	8b 40 0c             	mov    0xc(%eax),%eax
  8020c8:	89 04 24             	mov    %eax,(%esp)
  8020cb:	e8 ad 02 00 00       	call   80237d <nsipc_send>
}
  8020d0:	c9                   	leave  
  8020d1:	c3                   	ret    

008020d2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  8020d2:	55                   	push   %ebp
  8020d3:	89 e5                	mov    %esp,%ebp
  8020d5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  8020d8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8020df:	00 
  8020e0:	8b 45 10             	mov    0x10(%ebp),%eax
  8020e3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8020e7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020ee:	8b 45 08             	mov    0x8(%ebp),%eax
  8020f1:	8b 40 0c             	mov    0xc(%eax),%eax
  8020f4:	89 04 24             	mov    %eax,(%esp)
  8020f7:	e8 f4 02 00 00       	call   8023f0 <nsipc_recv>
}
  8020fc:	c9                   	leave  
  8020fd:	c3                   	ret    

008020fe <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  8020fe:	55                   	push   %ebp
  8020ff:	89 e5                	mov    %esp,%ebp
  802101:	56                   	push   %esi
  802102:	53                   	push   %ebx
  802103:	83 ec 20             	sub    $0x20,%esp
  802106:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802108:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80210b:	89 04 24             	mov    %eax,(%esp)
  80210e:	e8 68 f6 ff ff       	call   80177b <fd_alloc>
  802113:	89 c3                	mov    %eax,%ebx
  802115:	85 c0                	test   %eax,%eax
  802117:	78 21                	js     80213a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  802119:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802120:	00 
  802121:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802124:	89 44 24 04          	mov    %eax,0x4(%esp)
  802128:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80212f:	e8 f2 f0 ff ff       	call   801226 <sys_page_alloc>
  802134:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  802136:	85 c0                	test   %eax,%eax
  802138:	79 0a                	jns    802144 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  80213a:	89 34 24             	mov    %esi,(%esp)
  80213d:	e8 ff 01 00 00       	call   802341 <nsipc_close>
		return r;
  802142:	eb 28                	jmp    80216c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  802144:	8b 15 20 70 80 00    	mov    0x807020,%edx
  80214a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80214d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  80214f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802152:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  802159:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80215c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  80215f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802162:	89 04 24             	mov    %eax,(%esp)
  802165:	e8 e6 f5 ff ff       	call   801750 <fd2num>
  80216a:	89 c3                	mov    %eax,%ebx
}
  80216c:	89 d8                	mov    %ebx,%eax
  80216e:	83 c4 20             	add    $0x20,%esp
  802171:	5b                   	pop    %ebx
  802172:	5e                   	pop    %esi
  802173:	5d                   	pop    %ebp
  802174:	c3                   	ret    

00802175 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  802175:	55                   	push   %ebp
  802176:	89 e5                	mov    %esp,%ebp
  802178:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  80217b:	8b 45 10             	mov    0x10(%ebp),%eax
  80217e:	89 44 24 08          	mov    %eax,0x8(%esp)
  802182:	8b 45 0c             	mov    0xc(%ebp),%eax
  802185:	89 44 24 04          	mov    %eax,0x4(%esp)
  802189:	8b 45 08             	mov    0x8(%ebp),%eax
  80218c:	89 04 24             	mov    %eax,(%esp)
  80218f:	e8 61 01 00 00       	call   8022f5 <nsipc_socket>
  802194:	85 c0                	test   %eax,%eax
  802196:	78 05                	js     80219d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  802198:	e8 61 ff ff ff       	call   8020fe <alloc_sockfd>
}
  80219d:	c9                   	leave  
  80219e:	66 90                	xchg   %ax,%ax
  8021a0:	c3                   	ret    

008021a1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  8021a1:	55                   	push   %ebp
  8021a2:	89 e5                	mov    %esp,%ebp
  8021a4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  8021a7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  8021aa:	89 54 24 04          	mov    %edx,0x4(%esp)
  8021ae:	89 04 24             	mov    %eax,(%esp)
  8021b1:	e8 37 f6 ff ff       	call   8017ed <fd_lookup>
  8021b6:	85 c0                	test   %eax,%eax
  8021b8:	78 15                	js     8021cf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  8021ba:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8021bd:	8b 0a                	mov    (%edx),%ecx
  8021bf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8021c4:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  8021ca:	75 03                	jne    8021cf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  8021cc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  8021cf:	c9                   	leave  
  8021d0:	c3                   	ret    

008021d1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  8021d1:	55                   	push   %ebp
  8021d2:	89 e5                	mov    %esp,%ebp
  8021d4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8021d7:	8b 45 08             	mov    0x8(%ebp),%eax
  8021da:	e8 c2 ff ff ff       	call   8021a1 <fd2sockid>
  8021df:	85 c0                	test   %eax,%eax
  8021e1:	78 0f                	js     8021f2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  8021e3:	8b 55 0c             	mov    0xc(%ebp),%edx
  8021e6:	89 54 24 04          	mov    %edx,0x4(%esp)
  8021ea:	89 04 24             	mov    %eax,(%esp)
  8021ed:	e8 2d 01 00 00       	call   80231f <nsipc_listen>
}
  8021f2:	c9                   	leave  
  8021f3:	c3                   	ret    

008021f4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  8021f4:	55                   	push   %ebp
  8021f5:	89 e5                	mov    %esp,%ebp
  8021f7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  8021fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8021fd:	e8 9f ff ff ff       	call   8021a1 <fd2sockid>
  802202:	85 c0                	test   %eax,%eax
  802204:	78 16                	js     80221c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802206:	8b 55 10             	mov    0x10(%ebp),%edx
  802209:	89 54 24 08          	mov    %edx,0x8(%esp)
  80220d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802210:	89 54 24 04          	mov    %edx,0x4(%esp)
  802214:	89 04 24             	mov    %eax,(%esp)
  802217:	e8 54 02 00 00       	call   802470 <nsipc_connect>
}
  80221c:	c9                   	leave  
  80221d:	c3                   	ret    

0080221e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80221e:	55                   	push   %ebp
  80221f:	89 e5                	mov    %esp,%ebp
  802221:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802224:	8b 45 08             	mov    0x8(%ebp),%eax
  802227:	e8 75 ff ff ff       	call   8021a1 <fd2sockid>
  80222c:	85 c0                	test   %eax,%eax
  80222e:	78 0f                	js     80223f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802230:	8b 55 0c             	mov    0xc(%ebp),%edx
  802233:	89 54 24 04          	mov    %edx,0x4(%esp)
  802237:	89 04 24             	mov    %eax,(%esp)
  80223a:	e8 1c 01 00 00       	call   80235b <nsipc_shutdown>
}
  80223f:	c9                   	leave  
  802240:	c3                   	ret    

00802241 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802241:	55                   	push   %ebp
  802242:	89 e5                	mov    %esp,%ebp
  802244:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802247:	8b 45 08             	mov    0x8(%ebp),%eax
  80224a:	e8 52 ff ff ff       	call   8021a1 <fd2sockid>
  80224f:	85 c0                	test   %eax,%eax
  802251:	78 16                	js     802269 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802253:	8b 55 10             	mov    0x10(%ebp),%edx
  802256:	89 54 24 08          	mov    %edx,0x8(%esp)
  80225a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80225d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802261:	89 04 24             	mov    %eax,(%esp)
  802264:	e8 46 02 00 00       	call   8024af <nsipc_bind>
}
  802269:	c9                   	leave  
  80226a:	c3                   	ret    

0080226b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80226b:	55                   	push   %ebp
  80226c:	89 e5                	mov    %esp,%ebp
  80226e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802271:	8b 45 08             	mov    0x8(%ebp),%eax
  802274:	e8 28 ff ff ff       	call   8021a1 <fd2sockid>
  802279:	85 c0                	test   %eax,%eax
  80227b:	78 1f                	js     80229c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80227d:	8b 55 10             	mov    0x10(%ebp),%edx
  802280:	89 54 24 08          	mov    %edx,0x8(%esp)
  802284:	8b 55 0c             	mov    0xc(%ebp),%edx
  802287:	89 54 24 04          	mov    %edx,0x4(%esp)
  80228b:	89 04 24             	mov    %eax,(%esp)
  80228e:	e8 5b 02 00 00       	call   8024ee <nsipc_accept>
  802293:	85 c0                	test   %eax,%eax
  802295:	78 05                	js     80229c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  802297:	e8 62 fe ff ff       	call   8020fe <alloc_sockfd>
}
  80229c:	c9                   	leave  
  80229d:	8d 76 00             	lea    0x0(%esi),%esi
  8022a0:	c3                   	ret    
	...

008022b0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8022b0:	55                   	push   %ebp
  8022b1:	89 e5                	mov    %esp,%ebp
  8022b3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8022b6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8022bc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8022c3:	00 
  8022c4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8022cb:	00 
  8022cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022d0:	89 14 24             	mov    %edx,(%esp)
  8022d3:	e8 a8 08 00 00       	call   802b80 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  8022d8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8022df:	00 
  8022e0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8022e7:	00 
  8022e8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8022eb:	89 04 24             	mov    %eax,(%esp)
  8022ee:	e8 ff 08 00 00       	call   802bf2 <ipc_recv>
    return r;
}
  8022f3:	c9                   	leave  
  8022f4:	c3                   	ret    

008022f5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  8022f5:	55                   	push   %ebp
  8022f6:	89 e5                	mov    %esp,%ebp
  8022f8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  8022fb:	8b 45 08             	mov    0x8(%ebp),%eax
  8022fe:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802303:	8b 45 0c             	mov    0xc(%ebp),%eax
  802306:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80230b:	8b 45 10             	mov    0x10(%ebp),%eax
  80230e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802313:	b8 09 00 00 00       	mov    $0x9,%eax
  802318:	e8 93 ff ff ff       	call   8022b0 <nsipc>
}
  80231d:	c9                   	leave  
  80231e:	c3                   	ret    

0080231f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80231f:	55                   	push   %ebp
  802320:	89 e5                	mov    %esp,%ebp
  802322:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802325:	8b 45 08             	mov    0x8(%ebp),%eax
  802328:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80232d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802330:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802335:	b8 06 00 00 00       	mov    $0x6,%eax
  80233a:	e8 71 ff ff ff       	call   8022b0 <nsipc>
}
  80233f:	c9                   	leave  
  802340:	c3                   	ret    

00802341 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802341:	55                   	push   %ebp
  802342:	89 e5                	mov    %esp,%ebp
  802344:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802347:	8b 45 08             	mov    0x8(%ebp),%eax
  80234a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80234f:	b8 04 00 00 00       	mov    $0x4,%eax
  802354:	e8 57 ff ff ff       	call   8022b0 <nsipc>
}
  802359:	c9                   	leave  
  80235a:	c3                   	ret    

0080235b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80235b:	55                   	push   %ebp
  80235c:	89 e5                	mov    %esp,%ebp
  80235e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802361:	8b 45 08             	mov    0x8(%ebp),%eax
  802364:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802369:	8b 45 0c             	mov    0xc(%ebp),%eax
  80236c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802371:	b8 03 00 00 00       	mov    $0x3,%eax
  802376:	e8 35 ff ff ff       	call   8022b0 <nsipc>
}
  80237b:	c9                   	leave  
  80237c:	c3                   	ret    

0080237d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80237d:	55                   	push   %ebp
  80237e:	89 e5                	mov    %esp,%ebp
  802380:	53                   	push   %ebx
  802381:	83 ec 14             	sub    $0x14,%esp
  802384:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802387:	8b 45 08             	mov    0x8(%ebp),%eax
  80238a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  80238f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  802395:	7e 24                	jle    8023bb <nsipc_send+0x3e>
  802397:	c7 44 24 0c 74 35 80 	movl   $0x803574,0xc(%esp)
  80239e:	00 
  80239f:	c7 44 24 08 80 35 80 	movl   $0x803580,0x8(%esp)
  8023a6:	00 
  8023a7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8023ae:	00 
  8023af:	c7 04 24 95 35 80 00 	movl   $0x803595,(%esp)
  8023b6:	e8 75 df ff ff       	call   800330 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8023bb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8023bf:	8b 45 0c             	mov    0xc(%ebp),%eax
  8023c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023c6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  8023cd:	e8 b3 e8 ff ff       	call   800c85 <memmove>
	nsipcbuf.send.req_size = size;
  8023d2:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  8023d8:	8b 45 14             	mov    0x14(%ebp),%eax
  8023db:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  8023e0:	b8 08 00 00 00       	mov    $0x8,%eax
  8023e5:	e8 c6 fe ff ff       	call   8022b0 <nsipc>
}
  8023ea:	83 c4 14             	add    $0x14,%esp
  8023ed:	5b                   	pop    %ebx
  8023ee:	5d                   	pop    %ebp
  8023ef:	c3                   	ret    

008023f0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  8023f0:	55                   	push   %ebp
  8023f1:	89 e5                	mov    %esp,%ebp
  8023f3:	56                   	push   %esi
  8023f4:	53                   	push   %ebx
  8023f5:	83 ec 10             	sub    $0x10,%esp
  8023f8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  8023fb:	8b 45 08             	mov    0x8(%ebp),%eax
  8023fe:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802403:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802409:	8b 45 14             	mov    0x14(%ebp),%eax
  80240c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802411:	b8 07 00 00 00       	mov    $0x7,%eax
  802416:	e8 95 fe ff ff       	call   8022b0 <nsipc>
  80241b:	89 c3                	mov    %eax,%ebx
  80241d:	85 c0                	test   %eax,%eax
  80241f:	78 46                	js     802467 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802421:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802426:	7f 04                	jg     80242c <nsipc_recv+0x3c>
  802428:	39 c6                	cmp    %eax,%esi
  80242a:	7d 24                	jge    802450 <nsipc_recv+0x60>
  80242c:	c7 44 24 0c a1 35 80 	movl   $0x8035a1,0xc(%esp)
  802433:	00 
  802434:	c7 44 24 08 80 35 80 	movl   $0x803580,0x8(%esp)
  80243b:	00 
  80243c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802443:	00 
  802444:	c7 04 24 95 35 80 00 	movl   $0x803595,(%esp)
  80244b:	e8 e0 de ff ff       	call   800330 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802450:	89 44 24 08          	mov    %eax,0x8(%esp)
  802454:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80245b:	00 
  80245c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80245f:	89 04 24             	mov    %eax,(%esp)
  802462:	e8 1e e8 ff ff       	call   800c85 <memmove>
	}

	return r;
}
  802467:	89 d8                	mov    %ebx,%eax
  802469:	83 c4 10             	add    $0x10,%esp
  80246c:	5b                   	pop    %ebx
  80246d:	5e                   	pop    %esi
  80246e:	5d                   	pop    %ebp
  80246f:	c3                   	ret    

00802470 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802470:	55                   	push   %ebp
  802471:	89 e5                	mov    %esp,%ebp
  802473:	53                   	push   %ebx
  802474:	83 ec 14             	sub    $0x14,%esp
  802477:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80247a:	8b 45 08             	mov    0x8(%ebp),%eax
  80247d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802482:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802486:	8b 45 0c             	mov    0xc(%ebp),%eax
  802489:	89 44 24 04          	mov    %eax,0x4(%esp)
  80248d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802494:	e8 ec e7 ff ff       	call   800c85 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802499:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  80249f:	b8 05 00 00 00       	mov    $0x5,%eax
  8024a4:	e8 07 fe ff ff       	call   8022b0 <nsipc>
}
  8024a9:	83 c4 14             	add    $0x14,%esp
  8024ac:	5b                   	pop    %ebx
  8024ad:	5d                   	pop    %ebp
  8024ae:	c3                   	ret    

008024af <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8024af:	55                   	push   %ebp
  8024b0:	89 e5                	mov    %esp,%ebp
  8024b2:	53                   	push   %ebx
  8024b3:	83 ec 14             	sub    $0x14,%esp
  8024b6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8024b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8024bc:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8024c1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8024c5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8024c8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024cc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8024d3:	e8 ad e7 ff ff       	call   800c85 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8024d8:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  8024de:	b8 02 00 00 00       	mov    $0x2,%eax
  8024e3:	e8 c8 fd ff ff       	call   8022b0 <nsipc>
}
  8024e8:	83 c4 14             	add    $0x14,%esp
  8024eb:	5b                   	pop    %ebx
  8024ec:	5d                   	pop    %ebp
  8024ed:	c3                   	ret    

008024ee <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8024ee:	55                   	push   %ebp
  8024ef:	89 e5                	mov    %esp,%ebp
  8024f1:	83 ec 18             	sub    $0x18,%esp
  8024f4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8024f7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8024fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8024fd:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802502:	b8 01 00 00 00       	mov    $0x1,%eax
  802507:	e8 a4 fd ff ff       	call   8022b0 <nsipc>
  80250c:	89 c3                	mov    %eax,%ebx
  80250e:	85 c0                	test   %eax,%eax
  802510:	78 25                	js     802537 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802512:	be 10 60 80 00       	mov    $0x806010,%esi
  802517:	8b 06                	mov    (%esi),%eax
  802519:	89 44 24 08          	mov    %eax,0x8(%esp)
  80251d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802524:	00 
  802525:	8b 45 0c             	mov    0xc(%ebp),%eax
  802528:	89 04 24             	mov    %eax,(%esp)
  80252b:	e8 55 e7 ff ff       	call   800c85 <memmove>
		*addrlen = ret->ret_addrlen;
  802530:	8b 16                	mov    (%esi),%edx
  802532:	8b 45 10             	mov    0x10(%ebp),%eax
  802535:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802537:	89 d8                	mov    %ebx,%eax
  802539:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80253c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80253f:	89 ec                	mov    %ebp,%esp
  802541:	5d                   	pop    %ebp
  802542:	c3                   	ret    
	...

00802550 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802550:	55                   	push   %ebp
  802551:	89 e5                	mov    %esp,%ebp
  802553:	83 ec 18             	sub    $0x18,%esp
  802556:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802559:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80255c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80255f:	8b 45 08             	mov    0x8(%ebp),%eax
  802562:	89 04 24             	mov    %eax,(%esp)
  802565:	e8 f6 f1 ff ff       	call   801760 <fd2data>
  80256a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80256c:	c7 44 24 04 b6 35 80 	movl   $0x8035b6,0x4(%esp)
  802573:	00 
  802574:	89 34 24             	mov    %esi,(%esp)
  802577:	e8 4e e5 ff ff       	call   800aca <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80257c:	8b 43 04             	mov    0x4(%ebx),%eax
  80257f:	2b 03                	sub    (%ebx),%eax
  802581:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802587:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80258e:	00 00 00 
	stat->st_dev = &devpipe;
  802591:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  802598:	70 80 00 
	return 0;
}
  80259b:	b8 00 00 00 00       	mov    $0x0,%eax
  8025a0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8025a3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8025a6:	89 ec                	mov    %ebp,%esp
  8025a8:	5d                   	pop    %ebp
  8025a9:	c3                   	ret    

008025aa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8025aa:	55                   	push   %ebp
  8025ab:	89 e5                	mov    %esp,%ebp
  8025ad:	53                   	push   %ebx
  8025ae:	83 ec 14             	sub    $0x14,%esp
  8025b1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8025b4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8025b8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025bf:	e8 a6 eb ff ff       	call   80116a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8025c4:	89 1c 24             	mov    %ebx,(%esp)
  8025c7:	e8 94 f1 ff ff       	call   801760 <fd2data>
  8025cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025d0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025d7:	e8 8e eb ff ff       	call   80116a <sys_page_unmap>
}
  8025dc:	83 c4 14             	add    $0x14,%esp
  8025df:	5b                   	pop    %ebx
  8025e0:	5d                   	pop    %ebp
  8025e1:	c3                   	ret    

008025e2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8025e2:	55                   	push   %ebp
  8025e3:	89 e5                	mov    %esp,%ebp
  8025e5:	57                   	push   %edi
  8025e6:	56                   	push   %esi
  8025e7:	53                   	push   %ebx
  8025e8:	83 ec 2c             	sub    $0x2c,%esp
  8025eb:	89 c7                	mov    %eax,%edi
  8025ed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8025f0:	a1 74 70 80 00       	mov    0x807074,%eax
  8025f5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8025f8:	89 3c 24             	mov    %edi,(%esp)
  8025fb:	e8 44 06 00 00       	call   802c44 <pageref>
  802600:	89 c6                	mov    %eax,%esi
  802602:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802605:	89 04 24             	mov    %eax,(%esp)
  802608:	e8 37 06 00 00       	call   802c44 <pageref>
  80260d:	39 c6                	cmp    %eax,%esi
  80260f:	0f 94 c0             	sete   %al
  802612:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802615:	8b 15 74 70 80 00    	mov    0x807074,%edx
  80261b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80261e:	39 cb                	cmp    %ecx,%ebx
  802620:	75 08                	jne    80262a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802622:	83 c4 2c             	add    $0x2c,%esp
  802625:	5b                   	pop    %ebx
  802626:	5e                   	pop    %esi
  802627:	5f                   	pop    %edi
  802628:	5d                   	pop    %ebp
  802629:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80262a:	83 f8 01             	cmp    $0x1,%eax
  80262d:	75 c1                	jne    8025f0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80262f:	8b 52 58             	mov    0x58(%edx),%edx
  802632:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802636:	89 54 24 08          	mov    %edx,0x8(%esp)
  80263a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80263e:	c7 04 24 bd 35 80 00 	movl   $0x8035bd,(%esp)
  802645:	e8 ab dd ff ff       	call   8003f5 <cprintf>
  80264a:	eb a4                	jmp    8025f0 <_pipeisclosed+0xe>

0080264c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80264c:	55                   	push   %ebp
  80264d:	89 e5                	mov    %esp,%ebp
  80264f:	57                   	push   %edi
  802650:	56                   	push   %esi
  802651:	53                   	push   %ebx
  802652:	83 ec 1c             	sub    $0x1c,%esp
  802655:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802658:	89 34 24             	mov    %esi,(%esp)
  80265b:	e8 00 f1 ff ff       	call   801760 <fd2data>
  802660:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802662:	bf 00 00 00 00       	mov    $0x0,%edi
  802667:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80266b:	75 54                	jne    8026c1 <devpipe_write+0x75>
  80266d:	eb 60                	jmp    8026cf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80266f:	89 da                	mov    %ebx,%edx
  802671:	89 f0                	mov    %esi,%eax
  802673:	e8 6a ff ff ff       	call   8025e2 <_pipeisclosed>
  802678:	85 c0                	test   %eax,%eax
  80267a:	74 07                	je     802683 <devpipe_write+0x37>
  80267c:	b8 00 00 00 00       	mov    $0x0,%eax
  802681:	eb 53                	jmp    8026d6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802683:	90                   	nop
  802684:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802688:	e8 f8 eb ff ff       	call   801285 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80268d:	8b 43 04             	mov    0x4(%ebx),%eax
  802690:	8b 13                	mov    (%ebx),%edx
  802692:	83 c2 20             	add    $0x20,%edx
  802695:	39 d0                	cmp    %edx,%eax
  802697:	73 d6                	jae    80266f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802699:	89 c2                	mov    %eax,%edx
  80269b:	c1 fa 1f             	sar    $0x1f,%edx
  80269e:	c1 ea 1b             	shr    $0x1b,%edx
  8026a1:	01 d0                	add    %edx,%eax
  8026a3:	83 e0 1f             	and    $0x1f,%eax
  8026a6:	29 d0                	sub    %edx,%eax
  8026a8:	89 c2                	mov    %eax,%edx
  8026aa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8026ad:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8026b1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8026b5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8026b9:	83 c7 01             	add    $0x1,%edi
  8026bc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8026bf:	76 13                	jbe    8026d4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8026c1:	8b 43 04             	mov    0x4(%ebx),%eax
  8026c4:	8b 13                	mov    (%ebx),%edx
  8026c6:	83 c2 20             	add    $0x20,%edx
  8026c9:	39 d0                	cmp    %edx,%eax
  8026cb:	73 a2                	jae    80266f <devpipe_write+0x23>
  8026cd:	eb ca                	jmp    802699 <devpipe_write+0x4d>
  8026cf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  8026d4:	89 f8                	mov    %edi,%eax
}
  8026d6:	83 c4 1c             	add    $0x1c,%esp
  8026d9:	5b                   	pop    %ebx
  8026da:	5e                   	pop    %esi
  8026db:	5f                   	pop    %edi
  8026dc:	5d                   	pop    %ebp
  8026dd:	c3                   	ret    

008026de <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  8026de:	55                   	push   %ebp
  8026df:	89 e5                	mov    %esp,%ebp
  8026e1:	83 ec 28             	sub    $0x28,%esp
  8026e4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8026e7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8026ea:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8026ed:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8026f0:	89 3c 24             	mov    %edi,(%esp)
  8026f3:	e8 68 f0 ff ff       	call   801760 <fd2data>
  8026f8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8026fa:	be 00 00 00 00       	mov    $0x0,%esi
  8026ff:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802703:	75 4c                	jne    802751 <devpipe_read+0x73>
  802705:	eb 5b                	jmp    802762 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802707:	89 f0                	mov    %esi,%eax
  802709:	eb 5e                	jmp    802769 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80270b:	89 da                	mov    %ebx,%edx
  80270d:	89 f8                	mov    %edi,%eax
  80270f:	90                   	nop
  802710:	e8 cd fe ff ff       	call   8025e2 <_pipeisclosed>
  802715:	85 c0                	test   %eax,%eax
  802717:	74 07                	je     802720 <devpipe_read+0x42>
  802719:	b8 00 00 00 00       	mov    $0x0,%eax
  80271e:	eb 49                	jmp    802769 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802720:	e8 60 eb ff ff       	call   801285 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802725:	8b 03                	mov    (%ebx),%eax
  802727:	3b 43 04             	cmp    0x4(%ebx),%eax
  80272a:	74 df                	je     80270b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80272c:	89 c2                	mov    %eax,%edx
  80272e:	c1 fa 1f             	sar    $0x1f,%edx
  802731:	c1 ea 1b             	shr    $0x1b,%edx
  802734:	01 d0                	add    %edx,%eax
  802736:	83 e0 1f             	and    $0x1f,%eax
  802739:	29 d0                	sub    %edx,%eax
  80273b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802740:	8b 55 0c             	mov    0xc(%ebp),%edx
  802743:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802746:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802749:	83 c6 01             	add    $0x1,%esi
  80274c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80274f:	76 16                	jbe    802767 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802751:	8b 03                	mov    (%ebx),%eax
  802753:	3b 43 04             	cmp    0x4(%ebx),%eax
  802756:	75 d4                	jne    80272c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802758:	85 f6                	test   %esi,%esi
  80275a:	75 ab                	jne    802707 <devpipe_read+0x29>
  80275c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802760:	eb a9                	jmp    80270b <devpipe_read+0x2d>
  802762:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802767:	89 f0                	mov    %esi,%eax
}
  802769:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80276c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80276f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802772:	89 ec                	mov    %ebp,%esp
  802774:	5d                   	pop    %ebp
  802775:	c3                   	ret    

00802776 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802776:	55                   	push   %ebp
  802777:	89 e5                	mov    %esp,%ebp
  802779:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80277c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80277f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802783:	8b 45 08             	mov    0x8(%ebp),%eax
  802786:	89 04 24             	mov    %eax,(%esp)
  802789:	e8 5f f0 ff ff       	call   8017ed <fd_lookup>
  80278e:	85 c0                	test   %eax,%eax
  802790:	78 15                	js     8027a7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802792:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802795:	89 04 24             	mov    %eax,(%esp)
  802798:	e8 c3 ef ff ff       	call   801760 <fd2data>
	return _pipeisclosed(fd, p);
  80279d:	89 c2                	mov    %eax,%edx
  80279f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8027a2:	e8 3b fe ff ff       	call   8025e2 <_pipeisclosed>
}
  8027a7:	c9                   	leave  
  8027a8:	c3                   	ret    

008027a9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8027a9:	55                   	push   %ebp
  8027aa:	89 e5                	mov    %esp,%ebp
  8027ac:	83 ec 48             	sub    $0x48,%esp
  8027af:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8027b2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8027b5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8027b8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8027bb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8027be:	89 04 24             	mov    %eax,(%esp)
  8027c1:	e8 b5 ef ff ff       	call   80177b <fd_alloc>
  8027c6:	89 c3                	mov    %eax,%ebx
  8027c8:	85 c0                	test   %eax,%eax
  8027ca:	0f 88 42 01 00 00    	js     802912 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8027d0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8027d7:	00 
  8027d8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8027db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8027df:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8027e6:	e8 3b ea ff ff       	call   801226 <sys_page_alloc>
  8027eb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8027ed:	85 c0                	test   %eax,%eax
  8027ef:	0f 88 1d 01 00 00    	js     802912 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8027f5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8027f8:	89 04 24             	mov    %eax,(%esp)
  8027fb:	e8 7b ef ff ff       	call   80177b <fd_alloc>
  802800:	89 c3                	mov    %eax,%ebx
  802802:	85 c0                	test   %eax,%eax
  802804:	0f 88 f5 00 00 00    	js     8028ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80280a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802811:	00 
  802812:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802815:	89 44 24 04          	mov    %eax,0x4(%esp)
  802819:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802820:	e8 01 ea ff ff       	call   801226 <sys_page_alloc>
  802825:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802827:	85 c0                	test   %eax,%eax
  802829:	0f 88 d0 00 00 00    	js     8028ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80282f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802832:	89 04 24             	mov    %eax,(%esp)
  802835:	e8 26 ef ff ff       	call   801760 <fd2data>
  80283a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80283c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802843:	00 
  802844:	89 44 24 04          	mov    %eax,0x4(%esp)
  802848:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80284f:	e8 d2 e9 ff ff       	call   801226 <sys_page_alloc>
  802854:	89 c3                	mov    %eax,%ebx
  802856:	85 c0                	test   %eax,%eax
  802858:	0f 88 8e 00 00 00    	js     8028ec <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80285e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802861:	89 04 24             	mov    %eax,(%esp)
  802864:	e8 f7 ee ff ff       	call   801760 <fd2data>
  802869:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802870:	00 
  802871:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802875:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80287c:	00 
  80287d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802881:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802888:	e8 3b e9 ff ff       	call   8011c8 <sys_page_map>
  80288d:	89 c3                	mov    %eax,%ebx
  80288f:	85 c0                	test   %eax,%eax
  802891:	78 49                	js     8028dc <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802893:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  802898:	8b 08                	mov    (%eax),%ecx
  80289a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80289d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80289f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8028a2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8028a9:	8b 10                	mov    (%eax),%edx
  8028ab:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028ae:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8028b0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028b3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8028ba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8028bd:	89 04 24             	mov    %eax,(%esp)
  8028c0:	e8 8b ee ff ff       	call   801750 <fd2num>
  8028c5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8028c7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028ca:	89 04 24             	mov    %eax,(%esp)
  8028cd:	e8 7e ee ff ff       	call   801750 <fd2num>
  8028d2:	89 47 04             	mov    %eax,0x4(%edi)
  8028d5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8028da:	eb 36                	jmp    802912 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8028dc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8028e0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028e7:	e8 7e e8 ff ff       	call   80116a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8028ec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8028ef:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028f3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028fa:	e8 6b e8 ff ff       	call   80116a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8028ff:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802902:	89 44 24 04          	mov    %eax,0x4(%esp)
  802906:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80290d:	e8 58 e8 ff ff       	call   80116a <sys_page_unmap>
    err:
	return r;
}
  802912:	89 d8                	mov    %ebx,%eax
  802914:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802917:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80291a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80291d:	89 ec                	mov    %ebp,%esp
  80291f:	5d                   	pop    %ebp
  802920:	c3                   	ret    
	...

00802930 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802930:	55                   	push   %ebp
  802931:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802933:	b8 00 00 00 00       	mov    $0x0,%eax
  802938:	5d                   	pop    %ebp
  802939:	c3                   	ret    

0080293a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80293a:	55                   	push   %ebp
  80293b:	89 e5                	mov    %esp,%ebp
  80293d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802940:	c7 44 24 04 d0 35 80 	movl   $0x8035d0,0x4(%esp)
  802947:	00 
  802948:	8b 45 0c             	mov    0xc(%ebp),%eax
  80294b:	89 04 24             	mov    %eax,(%esp)
  80294e:	e8 77 e1 ff ff       	call   800aca <strcpy>
	return 0;
}
  802953:	b8 00 00 00 00       	mov    $0x0,%eax
  802958:	c9                   	leave  
  802959:	c3                   	ret    

0080295a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80295a:	55                   	push   %ebp
  80295b:	89 e5                	mov    %esp,%ebp
  80295d:	57                   	push   %edi
  80295e:	56                   	push   %esi
  80295f:	53                   	push   %ebx
  802960:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802966:	b8 00 00 00 00       	mov    $0x0,%eax
  80296b:	be 00 00 00 00       	mov    $0x0,%esi
  802970:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802974:	74 41                	je     8029b7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802976:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80297c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80297f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802981:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802987:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80298c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80298f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802993:	03 45 0c             	add    0xc(%ebp),%eax
  802996:	89 44 24 04          	mov    %eax,0x4(%esp)
  80299a:	89 3c 24             	mov    %edi,(%esp)
  80299d:	e8 e3 e2 ff ff       	call   800c85 <memmove>
		sys_cputs(buf, m);
  8029a2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8029a6:	89 3c 24             	mov    %edi,(%esp)
  8029a9:	e8 12 e5 ff ff       	call   800ec0 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8029ae:	01 de                	add    %ebx,%esi
  8029b0:	89 f0                	mov    %esi,%eax
  8029b2:	3b 75 10             	cmp    0x10(%ebp),%esi
  8029b5:	72 c5                	jb     80297c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  8029b7:	89 f0                	mov    %esi,%eax
  8029b9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  8029bf:	5b                   	pop    %ebx
  8029c0:	5e                   	pop    %esi
  8029c1:	5f                   	pop    %edi
  8029c2:	5d                   	pop    %ebp
  8029c3:	c3                   	ret    

008029c4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8029c4:	55                   	push   %ebp
  8029c5:	89 e5                	mov    %esp,%ebp
  8029c7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8029ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8029cd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8029d0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8029d7:	00 
  8029d8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8029db:	89 04 24             	mov    %eax,(%esp)
  8029de:	e8 dd e4 ff ff       	call   800ec0 <sys_cputs>
}
  8029e3:	c9                   	leave  
  8029e4:	c3                   	ret    

008029e5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8029e5:	55                   	push   %ebp
  8029e6:	89 e5                	mov    %esp,%ebp
  8029e8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8029eb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8029ef:	75 07                	jne    8029f8 <devcons_read+0x13>
  8029f1:	eb 2d                	jmp    802a20 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8029f3:	e8 8d e8 ff ff       	call   801285 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8029f8:	90                   	nop
  8029f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802a00:	e8 87 e4 ff ff       	call   800e8c <sys_cgetc>
  802a05:	85 c0                	test   %eax,%eax
  802a07:	74 ea                	je     8029f3 <devcons_read+0xe>
  802a09:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  802a0b:	85 c0                	test   %eax,%eax
  802a0d:	78 16                	js     802a25 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  802a0f:	83 f8 04             	cmp    $0x4,%eax
  802a12:	74 0c                	je     802a20 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802a14:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a17:	88 10                	mov    %dl,(%eax)
  802a19:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  802a1e:	eb 05                	jmp    802a25 <devcons_read+0x40>
  802a20:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802a25:	c9                   	leave  
  802a26:	c3                   	ret    

00802a27 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802a27:	55                   	push   %ebp
  802a28:	89 e5                	mov    %esp,%ebp
  802a2a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  802a2d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802a30:	89 04 24             	mov    %eax,(%esp)
  802a33:	e8 43 ed ff ff       	call   80177b <fd_alloc>
  802a38:	85 c0                	test   %eax,%eax
  802a3a:	78 3f                	js     802a7b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  802a3c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802a43:	00 
  802a44:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a47:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a4b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802a52:	e8 cf e7 ff ff       	call   801226 <sys_page_alloc>
  802a57:	85 c0                	test   %eax,%eax
  802a59:	78 20                	js     802a7b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  802a5b:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802a61:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a64:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802a66:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a69:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802a70:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a73:	89 04 24             	mov    %eax,(%esp)
  802a76:	e8 d5 ec ff ff       	call   801750 <fd2num>
}
  802a7b:	c9                   	leave  
  802a7c:	c3                   	ret    

00802a7d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  802a7d:	55                   	push   %ebp
  802a7e:	89 e5                	mov    %esp,%ebp
  802a80:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802a83:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802a86:	89 44 24 04          	mov    %eax,0x4(%esp)
  802a8a:	8b 45 08             	mov    0x8(%ebp),%eax
  802a8d:	89 04 24             	mov    %eax,(%esp)
  802a90:	e8 58 ed ff ff       	call   8017ed <fd_lookup>
  802a95:	85 c0                	test   %eax,%eax
  802a97:	78 11                	js     802aaa <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802a99:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802a9c:	8b 00                	mov    (%eax),%eax
  802a9e:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802aa4:	0f 94 c0             	sete   %al
  802aa7:	0f b6 c0             	movzbl %al,%eax
}
  802aaa:	c9                   	leave  
  802aab:	c3                   	ret    

00802aac <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  802aac:	55                   	push   %ebp
  802aad:	89 e5                	mov    %esp,%ebp
  802aaf:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802ab2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802ab9:	00 
  802aba:	8d 45 f7             	lea    -0x9(%ebp),%eax
  802abd:	89 44 24 04          	mov    %eax,0x4(%esp)
  802ac1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802ac8:	e8 86 ef ff ff       	call   801a53 <read>
	if (r < 0)
  802acd:	85 c0                	test   %eax,%eax
  802acf:	78 0f                	js     802ae0 <getchar+0x34>
		return r;
	if (r < 1)
  802ad1:	85 c0                	test   %eax,%eax
  802ad3:	7f 07                	jg     802adc <getchar+0x30>
  802ad5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  802ada:	eb 04                	jmp    802ae0 <getchar+0x34>
		return -E_EOF;
	return c;
  802adc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  802ae0:	c9                   	leave  
  802ae1:	c3                   	ret    
	...

00802ae4 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802ae4:	55                   	push   %ebp
  802ae5:	89 e5                	mov    %esp,%ebp
  802ae7:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  802aea:	83 3d 7c 70 80 00 00 	cmpl   $0x0,0x80707c
  802af1:	75 55                	jne    802b48 <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802af3:	e8 c1 e7 ff ff       	call   8012b9 <sys_getenvid>
  802af8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802aff:	00 
  802b00:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  802b07:	ee 
  802b08:	89 04 24             	mov    %eax,(%esp)
  802b0b:	e8 16 e7 ff ff       	call   801226 <sys_page_alloc>
  802b10:	85 c0                	test   %eax,%eax
  802b12:	74 1c                	je     802b30 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802b14:	c7 44 24 08 dc 35 80 	movl   $0x8035dc,0x8(%esp)
  802b1b:	00 
  802b1c:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802b23:	00 
  802b24:	c7 04 24 00 36 80 00 	movl   $0x803600,(%esp)
  802b2b:	e8 00 d8 ff ff       	call   800330 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802b30:	a1 74 70 80 00       	mov    0x807074,%eax
  802b35:	8b 40 4c             	mov    0x4c(%eax),%eax
  802b38:	c7 44 24 04 54 2b 80 	movl   $0x802b54,0x4(%esp)
  802b3f:	00 
  802b40:	89 04 24             	mov    %eax,(%esp)
  802b43:	e8 08 e5 ff ff       	call   801050 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  802b48:	8b 45 08             	mov    0x8(%ebp),%eax
  802b4b:	a3 7c 70 80 00       	mov    %eax,0x80707c
}
  802b50:	c9                   	leave  
  802b51:	c3                   	ret    
	...

00802b54 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802b54:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802b55:	a1 7c 70 80 00       	mov    0x80707c,%eax
	call *%eax
  802b5a:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802b5c:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802b5f:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802b64:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  802b68:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  802b6c:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  802b6e:	83 c4 08             	add    $0x8,%esp
    popal
  802b71:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  802b72:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  802b76:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  802b77:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  802b7b:	c3                   	ret    
  802b7c:	00 00                	add    %al,(%eax)
	...

00802b80 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  802b80:	55                   	push   %ebp
  802b81:	89 e5                	mov    %esp,%ebp
  802b83:	57                   	push   %edi
  802b84:	56                   	push   %esi
  802b85:	53                   	push   %ebx
  802b86:	83 ec 2c             	sub    $0x2c,%esp
  802b89:	8b 75 08             	mov    0x8(%ebp),%esi
  802b8c:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802b8f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802b92:	85 db                	test   %ebx,%ebx
  802b94:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802b99:	0f 45 c3             	cmovne %ebx,%eax
  802b9c:	8b 55 14             	mov    0x14(%ebp),%edx
  802b9f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802ba3:	89 44 24 08          	mov    %eax,0x8(%esp)
  802ba7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  802bab:	89 34 24             	mov    %esi,(%esp)
  802bae:	e8 3d e4 ff ff       	call   800ff0 <sys_ipc_try_send>
  802bb3:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802bb6:	75 0a                	jne    802bc2 <ipc_send+0x42>
      sys_yield();
  802bb8:	e8 c8 e6 ff ff       	call   801285 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  802bbd:	8d 76 00             	lea    0x0(%esi),%esi
  802bc0:	eb d0                	jmp    802b92 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802bc2:	85 c0                	test   %eax,%eax
  802bc4:	79 24                	jns    802bea <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802bc6:	89 44 24 10          	mov    %eax,0x10(%esp)
  802bca:	89 74 24 0c          	mov    %esi,0xc(%esp)
  802bce:	c7 44 24 08 10 36 80 	movl   $0x803610,0x8(%esp)
  802bd5:	00 
  802bd6:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802bdd:	00 
  802bde:	c7 04 24 34 36 80 00 	movl   $0x803634,(%esp)
  802be5:	e8 46 d7 ff ff       	call   800330 <_panic>
    else
      return;
  }
}
  802bea:	83 c4 2c             	add    $0x2c,%esp
  802bed:	5b                   	pop    %ebx
  802bee:	5e                   	pop    %esi
  802bef:	5f                   	pop    %edi
  802bf0:	5d                   	pop    %ebp
  802bf1:	c3                   	ret    

00802bf2 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802bf2:	55                   	push   %ebp
  802bf3:	89 e5                	mov    %esp,%ebp
  802bf5:	56                   	push   %esi
  802bf6:	53                   	push   %ebx
  802bf7:	83 ec 10             	sub    $0x10,%esp
  802bfa:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802bfd:	8b 45 0c             	mov    0xc(%ebp),%eax
  802c00:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802c03:	85 c0                	test   %eax,%eax
  802c05:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802c0a:	0f 44 c2             	cmove  %edx,%eax
  802c0d:	89 04 24             	mov    %eax,(%esp)
  802c10:	e8 7e e3 ff ff       	call   800f93 <sys_ipc_recv>
  802c15:	85 c0                	test   %eax,%eax
  802c17:	78 24                	js     802c3d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802c19:	85 db                	test   %ebx,%ebx
  802c1b:	74 0a                	je     802c27 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802c1d:	a1 74 70 80 00       	mov    0x807074,%eax
  802c22:	8b 40 74             	mov    0x74(%eax),%eax
  802c25:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802c27:	85 f6                	test   %esi,%esi
  802c29:	74 0a                	je     802c35 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802c2b:	a1 74 70 80 00       	mov    0x807074,%eax
  802c30:	8b 40 78             	mov    0x78(%eax),%eax
  802c33:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802c35:	a1 74 70 80 00       	mov    0x807074,%eax
  802c3a:	8b 40 70             	mov    0x70(%eax),%eax
}
  802c3d:	83 c4 10             	add    $0x10,%esp
  802c40:	5b                   	pop    %ebx
  802c41:	5e                   	pop    %esi
  802c42:	5d                   	pop    %ebp
  802c43:	c3                   	ret    

00802c44 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802c44:	55                   	push   %ebp
  802c45:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802c47:	8b 45 08             	mov    0x8(%ebp),%eax
  802c4a:	89 c2                	mov    %eax,%edx
  802c4c:	c1 ea 16             	shr    $0x16,%edx
  802c4f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802c56:	f6 c2 01             	test   $0x1,%dl
  802c59:	74 26                	je     802c81 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802c5b:	c1 e8 0c             	shr    $0xc,%eax
  802c5e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802c65:	a8 01                	test   $0x1,%al
  802c67:	74 18                	je     802c81 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802c69:	c1 e8 0c             	shr    $0xc,%eax
  802c6c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802c6f:	c1 e2 02             	shl    $0x2,%edx
  802c72:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802c77:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802c7c:	0f b7 c0             	movzwl %ax,%eax
  802c7f:	eb 05                	jmp    802c86 <pageref+0x42>
  802c81:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802c86:	5d                   	pop    %ebp
  802c87:	c3                   	ret    
	...

00802c90 <__udivdi3>:
  802c90:	55                   	push   %ebp
  802c91:	89 e5                	mov    %esp,%ebp
  802c93:	57                   	push   %edi
  802c94:	56                   	push   %esi
  802c95:	83 ec 10             	sub    $0x10,%esp
  802c98:	8b 45 14             	mov    0x14(%ebp),%eax
  802c9b:	8b 55 08             	mov    0x8(%ebp),%edx
  802c9e:	8b 75 10             	mov    0x10(%ebp),%esi
  802ca1:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802ca4:	85 c0                	test   %eax,%eax
  802ca6:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802ca9:	75 35                	jne    802ce0 <__udivdi3+0x50>
  802cab:	39 fe                	cmp    %edi,%esi
  802cad:	77 61                	ja     802d10 <__udivdi3+0x80>
  802caf:	85 f6                	test   %esi,%esi
  802cb1:	75 0b                	jne    802cbe <__udivdi3+0x2e>
  802cb3:	b8 01 00 00 00       	mov    $0x1,%eax
  802cb8:	31 d2                	xor    %edx,%edx
  802cba:	f7 f6                	div    %esi
  802cbc:	89 c6                	mov    %eax,%esi
  802cbe:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802cc1:	31 d2                	xor    %edx,%edx
  802cc3:	89 f8                	mov    %edi,%eax
  802cc5:	f7 f6                	div    %esi
  802cc7:	89 c7                	mov    %eax,%edi
  802cc9:	89 c8                	mov    %ecx,%eax
  802ccb:	f7 f6                	div    %esi
  802ccd:	89 c1                	mov    %eax,%ecx
  802ccf:	89 fa                	mov    %edi,%edx
  802cd1:	89 c8                	mov    %ecx,%eax
  802cd3:	83 c4 10             	add    $0x10,%esp
  802cd6:	5e                   	pop    %esi
  802cd7:	5f                   	pop    %edi
  802cd8:	5d                   	pop    %ebp
  802cd9:	c3                   	ret    
  802cda:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802ce0:	39 f8                	cmp    %edi,%eax
  802ce2:	77 1c                	ja     802d00 <__udivdi3+0x70>
  802ce4:	0f bd d0             	bsr    %eax,%edx
  802ce7:	83 f2 1f             	xor    $0x1f,%edx
  802cea:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802ced:	75 39                	jne    802d28 <__udivdi3+0x98>
  802cef:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802cf2:	0f 86 a0 00 00 00    	jbe    802d98 <__udivdi3+0x108>
  802cf8:	39 f8                	cmp    %edi,%eax
  802cfa:	0f 82 98 00 00 00    	jb     802d98 <__udivdi3+0x108>
  802d00:	31 ff                	xor    %edi,%edi
  802d02:	31 c9                	xor    %ecx,%ecx
  802d04:	89 c8                	mov    %ecx,%eax
  802d06:	89 fa                	mov    %edi,%edx
  802d08:	83 c4 10             	add    $0x10,%esp
  802d0b:	5e                   	pop    %esi
  802d0c:	5f                   	pop    %edi
  802d0d:	5d                   	pop    %ebp
  802d0e:	c3                   	ret    
  802d0f:	90                   	nop
  802d10:	89 d1                	mov    %edx,%ecx
  802d12:	89 fa                	mov    %edi,%edx
  802d14:	89 c8                	mov    %ecx,%eax
  802d16:	31 ff                	xor    %edi,%edi
  802d18:	f7 f6                	div    %esi
  802d1a:	89 c1                	mov    %eax,%ecx
  802d1c:	89 fa                	mov    %edi,%edx
  802d1e:	89 c8                	mov    %ecx,%eax
  802d20:	83 c4 10             	add    $0x10,%esp
  802d23:	5e                   	pop    %esi
  802d24:	5f                   	pop    %edi
  802d25:	5d                   	pop    %ebp
  802d26:	c3                   	ret    
  802d27:	90                   	nop
  802d28:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d2c:	89 f2                	mov    %esi,%edx
  802d2e:	d3 e0                	shl    %cl,%eax
  802d30:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802d33:	b8 20 00 00 00       	mov    $0x20,%eax
  802d38:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802d3b:	89 c1                	mov    %eax,%ecx
  802d3d:	d3 ea                	shr    %cl,%edx
  802d3f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d43:	0b 55 ec             	or     -0x14(%ebp),%edx
  802d46:	d3 e6                	shl    %cl,%esi
  802d48:	89 c1                	mov    %eax,%ecx
  802d4a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802d4d:	89 fe                	mov    %edi,%esi
  802d4f:	d3 ee                	shr    %cl,%esi
  802d51:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d55:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802d58:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802d5b:	d3 e7                	shl    %cl,%edi
  802d5d:	89 c1                	mov    %eax,%ecx
  802d5f:	d3 ea                	shr    %cl,%edx
  802d61:	09 d7                	or     %edx,%edi
  802d63:	89 f2                	mov    %esi,%edx
  802d65:	89 f8                	mov    %edi,%eax
  802d67:	f7 75 ec             	divl   -0x14(%ebp)
  802d6a:	89 d6                	mov    %edx,%esi
  802d6c:	89 c7                	mov    %eax,%edi
  802d6e:	f7 65 e8             	mull   -0x18(%ebp)
  802d71:	39 d6                	cmp    %edx,%esi
  802d73:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802d76:	72 30                	jb     802da8 <__udivdi3+0x118>
  802d78:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802d7b:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802d7f:	d3 e2                	shl    %cl,%edx
  802d81:	39 c2                	cmp    %eax,%edx
  802d83:	73 05                	jae    802d8a <__udivdi3+0xfa>
  802d85:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802d88:	74 1e                	je     802da8 <__udivdi3+0x118>
  802d8a:	89 f9                	mov    %edi,%ecx
  802d8c:	31 ff                	xor    %edi,%edi
  802d8e:	e9 71 ff ff ff       	jmp    802d04 <__udivdi3+0x74>
  802d93:	90                   	nop
  802d94:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802d98:	31 ff                	xor    %edi,%edi
  802d9a:	b9 01 00 00 00       	mov    $0x1,%ecx
  802d9f:	e9 60 ff ff ff       	jmp    802d04 <__udivdi3+0x74>
  802da4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802da8:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802dab:	31 ff                	xor    %edi,%edi
  802dad:	89 c8                	mov    %ecx,%eax
  802daf:	89 fa                	mov    %edi,%edx
  802db1:	83 c4 10             	add    $0x10,%esp
  802db4:	5e                   	pop    %esi
  802db5:	5f                   	pop    %edi
  802db6:	5d                   	pop    %ebp
  802db7:	c3                   	ret    
	...

00802dc0 <__umoddi3>:
  802dc0:	55                   	push   %ebp
  802dc1:	89 e5                	mov    %esp,%ebp
  802dc3:	57                   	push   %edi
  802dc4:	56                   	push   %esi
  802dc5:	83 ec 20             	sub    $0x20,%esp
  802dc8:	8b 55 14             	mov    0x14(%ebp),%edx
  802dcb:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802dce:	8b 7d 10             	mov    0x10(%ebp),%edi
  802dd1:	8b 75 0c             	mov    0xc(%ebp),%esi
  802dd4:	85 d2                	test   %edx,%edx
  802dd6:	89 c8                	mov    %ecx,%eax
  802dd8:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802ddb:	75 13                	jne    802df0 <__umoddi3+0x30>
  802ddd:	39 f7                	cmp    %esi,%edi
  802ddf:	76 3f                	jbe    802e20 <__umoddi3+0x60>
  802de1:	89 f2                	mov    %esi,%edx
  802de3:	f7 f7                	div    %edi
  802de5:	89 d0                	mov    %edx,%eax
  802de7:	31 d2                	xor    %edx,%edx
  802de9:	83 c4 20             	add    $0x20,%esp
  802dec:	5e                   	pop    %esi
  802ded:	5f                   	pop    %edi
  802dee:	5d                   	pop    %ebp
  802def:	c3                   	ret    
  802df0:	39 f2                	cmp    %esi,%edx
  802df2:	77 4c                	ja     802e40 <__umoddi3+0x80>
  802df4:	0f bd ca             	bsr    %edx,%ecx
  802df7:	83 f1 1f             	xor    $0x1f,%ecx
  802dfa:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802dfd:	75 51                	jne    802e50 <__umoddi3+0x90>
  802dff:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802e02:	0f 87 e0 00 00 00    	ja     802ee8 <__umoddi3+0x128>
  802e08:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e0b:	29 f8                	sub    %edi,%eax
  802e0d:	19 d6                	sbb    %edx,%esi
  802e0f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802e12:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e15:	89 f2                	mov    %esi,%edx
  802e17:	83 c4 20             	add    $0x20,%esp
  802e1a:	5e                   	pop    %esi
  802e1b:	5f                   	pop    %edi
  802e1c:	5d                   	pop    %ebp
  802e1d:	c3                   	ret    
  802e1e:	66 90                	xchg   %ax,%ax
  802e20:	85 ff                	test   %edi,%edi
  802e22:	75 0b                	jne    802e2f <__umoddi3+0x6f>
  802e24:	b8 01 00 00 00       	mov    $0x1,%eax
  802e29:	31 d2                	xor    %edx,%edx
  802e2b:	f7 f7                	div    %edi
  802e2d:	89 c7                	mov    %eax,%edi
  802e2f:	89 f0                	mov    %esi,%eax
  802e31:	31 d2                	xor    %edx,%edx
  802e33:	f7 f7                	div    %edi
  802e35:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802e38:	f7 f7                	div    %edi
  802e3a:	eb a9                	jmp    802de5 <__umoddi3+0x25>
  802e3c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e40:	89 c8                	mov    %ecx,%eax
  802e42:	89 f2                	mov    %esi,%edx
  802e44:	83 c4 20             	add    $0x20,%esp
  802e47:	5e                   	pop    %esi
  802e48:	5f                   	pop    %edi
  802e49:	5d                   	pop    %ebp
  802e4a:	c3                   	ret    
  802e4b:	90                   	nop
  802e4c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802e50:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e54:	d3 e2                	shl    %cl,%edx
  802e56:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802e59:	ba 20 00 00 00       	mov    $0x20,%edx
  802e5e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802e61:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802e64:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802e68:	89 fa                	mov    %edi,%edx
  802e6a:	d3 ea                	shr    %cl,%edx
  802e6c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e70:	0b 55 f4             	or     -0xc(%ebp),%edx
  802e73:	d3 e7                	shl    %cl,%edi
  802e75:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802e79:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802e7c:	89 f2                	mov    %esi,%edx
  802e7e:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802e81:	89 c7                	mov    %eax,%edi
  802e83:	d3 ea                	shr    %cl,%edx
  802e85:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e89:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802e8c:	89 c2                	mov    %eax,%edx
  802e8e:	d3 e6                	shl    %cl,%esi
  802e90:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802e94:	d3 ea                	shr    %cl,%edx
  802e96:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802e9a:	09 d6                	or     %edx,%esi
  802e9c:	89 f0                	mov    %esi,%eax
  802e9e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802ea1:	d3 e7                	shl    %cl,%edi
  802ea3:	89 f2                	mov    %esi,%edx
  802ea5:	f7 75 f4             	divl   -0xc(%ebp)
  802ea8:	89 d6                	mov    %edx,%esi
  802eaa:	f7 65 e8             	mull   -0x18(%ebp)
  802ead:	39 d6                	cmp    %edx,%esi
  802eaf:	72 2b                	jb     802edc <__umoddi3+0x11c>
  802eb1:	39 c7                	cmp    %eax,%edi
  802eb3:	72 23                	jb     802ed8 <__umoddi3+0x118>
  802eb5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802eb9:	29 c7                	sub    %eax,%edi
  802ebb:	19 d6                	sbb    %edx,%esi
  802ebd:	89 f0                	mov    %esi,%eax
  802ebf:	89 f2                	mov    %esi,%edx
  802ec1:	d3 ef                	shr    %cl,%edi
  802ec3:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ec7:	d3 e0                	shl    %cl,%eax
  802ec9:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ecd:	09 f8                	or     %edi,%eax
  802ecf:	d3 ea                	shr    %cl,%edx
  802ed1:	83 c4 20             	add    $0x20,%esp
  802ed4:	5e                   	pop    %esi
  802ed5:	5f                   	pop    %edi
  802ed6:	5d                   	pop    %ebp
  802ed7:	c3                   	ret    
  802ed8:	39 d6                	cmp    %edx,%esi
  802eda:	75 d9                	jne    802eb5 <__umoddi3+0xf5>
  802edc:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802edf:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802ee2:	eb d1                	jmp    802eb5 <__umoddi3+0xf5>
  802ee4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802ee8:	39 f2                	cmp    %esi,%edx
  802eea:	0f 82 18 ff ff ff    	jb     802e08 <__umoddi3+0x48>
  802ef0:	e9 1d ff ff ff       	jmp    802e12 <__umoddi3+0x52>
